def xor_matching(m, k)
  return -1 if 2 ** (m) <= k

  if m == 0
    return -1 if k != 0
    return [0, 0]
  end

  if m == 1
    return -1 if k != 0
    return [0, 0, 1, 1]
  end

  subsequence = Array.new(2 ** (m)) { |i| i }
  subsequence.delete_at(k)
  [subsequence, k, subsequence.reverse, k].flatten!
end

m, k = gets.split.map(&:to_i)
puts xor_matching(m, k)
