package main import ("bufio"; "fmt"; "io"; "os") import "sort" func min(l int) int { if l == 0 { return 0 } sum := 0 n := 1 k := 1 for 2 * n + 1 <= l { sum += (n + 1) * k k++ n = 2 * n + 1 } return sum + (l - n) * k } func show(l, c, start int) { Assert(c <= l * (l - 1) / 2) if c == l * (l - 1) / 2 { for i := 0; i < l; i++ { fmt.Print(" ", start + i) } return } k := sort.Search((l - 1) / 2, func (n int) bool { a := n + 1 b := l - 1 - a return c - (l - 1) - min(a) > b * (b - 1) / 2 }) fmt.Print(" ", start + k) mink := min(k) show(k, mink, start) show(l - 1 - k, c - (l - 1) - mink, start + k + 1) } func main() { Q := ScanInt(1, 1e5) for q := 0; q < Q; q++ { NewLine() L := ScanInt(1, 1e5) C := ScanInt(0, 1e9) if C > L * (L - 1) / 2 || C < min(L) { fmt.Println(-1) continue } show(L, C, 1) fmt.Println() } } // Boilerplate func Assert(condition bool, items... interface{}) { if !condition { panic("assertion failed: " + fmt.Sprint(items...)) } } func Log(items... interface{}) { fmt.Println(items...) } var Input = bufio.NewReader(os.Stdin) func ReadByte() byte { b, e := Input.ReadByte() if e != nil { panic(e) } return b } func MaybeReadByte() (byte, bool) { b, e := Input.ReadByte() if e != nil { if e == io.EOF { return 0, false } panic(e) } return b, true } func UnreadByte() { e := Input.UnreadByte() if e != nil { panic(e) } } func NewLine() { for { b := ReadByte() switch b { case ' ', '\t', '\r': // keep looking case '\n': return default: panic(fmt.Sprintf("expecting newline, but found character <%c>", b)) } } } func ScanInt(low, high int) int { return int(ScanInt64(int64(low), int64(high))) } func ScanUint(low, high uint) uint { return uint(ScanUint64(uint64(low), uint64(high))) } func ScanInt64(low, high int64) int64 { Assert(low <= high) for { b := ReadByte() switch b { case ' ', '\t', '\r': // keep looking case '\n': panic(fmt.Sprintf( "unexpected newline; expecting range %d..%d", low, high)) case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9': if high < 0 { panic(fmt.Sprintf( "found <%c> but expecting range %d..%d", b, low, high)) } lw := low if lw < 0 { lw = 0 } UnreadByte() x, e := _scanu64(uint64(lw), uint64(high)) if e != "" { panic(fmt.Sprintf("%s %d..%d", e, low, high)) } return int64(x) case '-': if low > 0 { panic(fmt.Sprintf( "found minus sign but expecting range %d..%d", low, high)) } h := high if h > 0 { h = 0 } x, e := _scanu64(uint64(-h), uint64(-low)) if e != "" { panic(fmt.Sprintf( "-%s %d..%d", e, low, high)) } return -int64(x) default: panic(fmt.Sprintf( "unexpected character <%c>; expecting range %d..%d", b, low, high)) } } } func ScanUint64(low, high uint64) uint64 { Assert(low <= high) for { b := ReadByte() switch b { case ' ', '\t', '\r': // keep looking case '\n': panic(fmt.Sprintf( "unexpected newline; expecting range %d..%d", low, high)) case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9': UnreadByte() x, e := _scanu64(low, high) if e != "" { panic(fmt.Sprintf("%s %d..%d", e, low, high)) } return x default: panic(fmt.Sprintf( "unexpected character <%c>; expecting range %d..%d", b, low, high)) } } } func _scanu64(low, high uint64) (result uint64, err string) { x := uint64(0) buildnumber: for { b, ok := MaybeReadByte() if !ok { break buildnumber } switch b { case ' ', '\t', '\r': break buildnumber case '\n': UnreadByte() break buildnumber case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9': d := uint64(b - '0') if (high - d) / 10 < x { return x, fmt.Sprintf("%d%c... not in range", x, b) } x = x * 10 + d default: return x, fmt.Sprintf("%d%c found; expecting range", x, b) } } if x < low || x > high { return x, fmt.Sprintf("%d not in range", x) } return x, "" } func ScanBytes(short, long int) []byte { Assert(1 <= short && short <= long) var b byte buf := make([]byte, long) skipws: for { b = ReadByte() switch b { case ' ', '\t', '\r': // keep looking case '\n': panic(fmt.Sprintf("unexpected newline; expecting string")) default: break skipws } } buf[0] = b length := 1 buildstring: for { var ok bool b, ok = MaybeReadByte() if !ok { break buildstring } switch b { case ' ', '\t', '\r': break buildstring case '\n': UnreadByte() break buildstring default: if length >= long { panic(fmt.Sprintf("string length not in range %d..%d", short, long)) } buf[length] = b length++ } } if length < short { panic(fmt.Sprintf("string length not in range %d..%d", short, long)) } return buf[:length] } func ScanString(short, long int) string { return string(ScanBytes(short, long)) }