local DBG = false
local function dbgpr(...)
    if DBG then
        io.write("[dbg]")
        print(...)
    end
end

local floor = math.floor

local function solve(M, K)
    local lim = floor(2^M) - 1
    if K > lim then
        print(-1)
        error()
        return
    end
    if K == 0 then
        local sb = {}
        for i=0,lim do
            table.insert(sb, i)
            table.insert(sb, i)
        end
        print(table.concat(sb, ' '))
        os.execute("sleep 0.5")
        return
    end
    local len = floor(2^M) + 1
    local ans = {}
    table.insert(ans, 0)
    table.insert(ans, 0)
    table.insert(ans, K)
    local sum = K
    for i=lim,1,-1 do
        if i ~= K then
            table.insert(ans, i)
            sum = sum ~ i
        end
    end
    table.insert(ans, K)
    sum = sum ~ K
    if sum == K then
        dbgpr("OK")
    else
        dbgpr("NG")
        print(-1)
        os.execute("sleep 1.2")
        return
    end
    for i=1,lim do
        if i ~= K then
            table.insert(ans, i)
        end
    end
    print(table.concat(ans, ' '))
end

local M,K = io.read("n", "n")
solve(M,K)

--[[
for M=0,5 do
    local lim = floor(2^M) - 1
    for K=0,lim do
        dbgpr("solve " .. M .. " " .. K)
        solve(M,K)
    end
end
]]