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 = []
  r = []
  used = Array.new(2**M)
  used[0] = used[K] = true
  if K == 1
    l = [2, 0, K, 0, 2]
    r = [2^K, K, 2^K]
    used[2] = used[2^K] = true
  else
    l = [1, 0, K, 0, 1]
    r = [1^K, K, 1^K]
    used[1] = used[1^K] = true
  end
  (0...2**M).each do |i|
    next if used[i]
    used[i] = used[i^K] = true
    l.unshift(i)
    l.push(i)
    r.unshift(i^K)
    r.push(i^K)
  end
  l + r
end

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