local m, k = io.read("*n", "*n")
local n = 2^m
if(k == 0) then
  io.write("0 0")
  for i = 1, n - 1 do
    io.write(" " .. i .. " " .. i)
  end
  io.write("\n")
elseif(n - 1 <= k) then
  print(-1)
else
  local rem = (n - 1) - k
  io.write(n - 1)
  for i = n - 2, 0, -1 do
    if(i ~= k and i ~= rem) then
      io.write(" " .. i)
    end
  end
  io.write(" " .. k .. " " .. n - 1 .. " " .. rem .. " " .. k)
  for i = 0, n - 2 do
    if(i ~= k and i ~= rem) then
      io.write(" " .. i)
    end
  end
  io.write(" " .. rem)
  io.write("\n")
end
