def solve
  return [-1] unless K < 2**M
  return [-1] if M==1 && K==1
  return (0...2**M).to_a.map{|i| [i, i]}.flatten if K.zero?
  l = (K==1 ? 2 : 1)
#   l = 2**K.to_s(2).index(?1)
  r = K^l
  res = [l, K, l, r, K, r]
  (0...2**M).each do |i|
    next if i == K
    next if i == l
    next if i == r
    res.unshift(i)
    res.push(i)
  end
  res
end

M, K = gets.split.map &:to_i
puts solve*" "
