#!/bin/ruby q = gets.strip.to_i for a0 in (0..q-1) len,c = gets.strip.split(' ') len = len.to_i c = c.to_i max = (1..[len-1,1].max).inject(:+) min = [len-1, 0].max if c > max || c < min puts -1 next end if len == 1 && c == 0 puts 1 next end if c == max puts (1..len).to_a.reverse.join(' ') next end v = c ops = [] a = (1..len).to_a new_min = min until false do if v < c ops << v if a.include?(v) break end if a.include?(new_min) #puts "#{a}, #{ops}, #{new_min}" ops << new_min v -= new_min a.delete(new_min) new_min -= 1 else new_min -= 1 end end a = (1..len).to_a rest = a - ops res = ops + rest #puts "#{a}, #{rest}, #{ops}, #{res}" puts res.join(' ') end