import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;

void main() {
    int m, k;
    scan(m, k);

    int lim = 1 << m;

    if (k >= lim) {
        writeln(-1);
        return;
    }

    if (m == 1 && k == 1) {
        writeln(-1);
        return;
    }

    auto ans = new int[](1 << (m + 1));

    if (k == 0) {
        foreach (i ; 0 .. 1 << m) {
            ans[2*i] = ans[2*i + 1] = i;
        }
    }
    else {
        auto deq = Deque!(int)(1 << (m + 1));
        auto used = new bool[](1 << m);
        deq.pushBack(k);

        if (k == 1) {
            deq.pushBack(2);
            deq.pushBack(3);
            deq.pushFront(2);
            deq.pushFront(3);
            used[2] = used[3] = 1;
        }
        else if (nibeki(k)) {
            deq.pushBack((1 << bitlen(k)) + 1);
            deq.pushBack(1);
            deq.pushFront((1 << bitlen(k)) + 1);
            deq.pushFront(1);
            used[1] = used[(1 << bitlen(k)) + 1] = 1;
        }
        else {
            deq.pushBack(1 << bitlen(k));
            deq.pushBack((1 << bitlen(k)) ^ k);
            deq.pushFront(1 << bitlen(k));
            deq.pushFront((1 << bitlen(k)) ^ k);
            used[1 << bitlen(k)] = used[(1 << bitlen(k)) ^ k] = 1;
        }

        deq.pushBack(k);

        foreach (i ; 0 .. 1 << m) {
            if (!used[i] && i != k) {
                deq.pushFront(i);
                deq.pushBack(i);
            }
        }

        //deq.pushBack(k);

        foreach (i ; 0 .. 1 << (m + 1)) {
            ans[i] = deq.front;
            deq.removeFront();
        }
    }

    writefln("%(%s %)", ans);
}


bool nibeki(int x) {
    return x == (1 << bsf(x));
}

int bitlen(int x) {
    return (x > 0 ? bitlen(x >> 1) + 1 : -1);
}

struct Deque(T) {
    private {
        int N, head, tail;
        T[] deq;
    }

    this(int n) {
        N = n + 1;
        deq = new T[](N + 1);
    }

    bool empty() {
        return head == tail;
    }

    bool full() {
        return head == ((tail + 1) % N);
    }

    int length() {
        return (tail - head + N) % N;
    }

    T front() {
        assert(!empty);
        return deq[head];
    }

    T back() {
        assert(!empty);
        return deq[(tail - 1 + N) % N];
    }

    void pushFront(T x) {
        assert(!full);
        head = (head - 1 + N) % N;
        deq[head] = x;
    }

    void pushBack(T x) {
        assert(!full);
        deq[tail++] = x;
        tail %= N;
    }

    void popFront() {
        assert(!empty);
        head = (head + 1) % N;
    }

    void popBack() {
        assert(!empty);
        tail = (tail - 1 + N) % N;
    }

    alias insert = pushBack;
    alias removeFront = popFront;
    alias removeBack = popBack;

    T opIndex(size_t index)
    in {
        assert(0 <= index && index < length);
    }
    body {
        return deq[(head + index) % N];
    }

    alias opDollar = length;
}



struct UnionFind {
    int N;
    int[] parent; // 根は -(連結成分のサイズ) としておく

    this(int n) 
    in {
        assert(n > 0);
    }
    body {
        N = n;
        parent = new int[](N);
        parent[] = -1;
    }

    int root(int x)
    in {
        assert(0 <= x && x < N);
    }
    body {
        if (parent[x] < 0) return x;
        else return parent[x] = root(parent[x]);
    }

    int size(int x)
    in {
        assert(0 <= x && x < N);
    }
    body {
        return -parent[root(x)];
    }

    bool same(int x, int y)
    in {
        assert(0 <= x && x < N);
        assert(0 <= y && y < N);
    }
    body {
        return root(x) == root(y);
    }

    bool merge(int x, int y)
    in {
        assert(0 <= x && x < N);
        assert(0 <= y && y < N);
    }
    body {
        import std.algorithm : swap;

        x = root(x);
        y = root(y);

        if (x == y) return false;
        if (size(x) < size(y)) swap(x, y);

        // size(x) >= size(y)
        parent[x] += parent[y];
        parent[y] = x;

        return true;
    }
}

















int[][] readGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new int[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v;
        scan(u, v);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= v;
        if (isUndirected) {
            adj[v] ~= u;
        }
    }

    return adj;
}

alias Edge = Tuple!(int, "to", int, "cost");

Edge[][] readWeightedGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new Edge[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v, c;
        scan(u, v, c);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= Edge(v, c);
        if (isUndirected) {
            adj[v] ~= Edge(u, c);
        }
    }

    return adj;
}

void yes(bool b) {
    writeln(b ? "Yes" : "No");
}

void YES(bool b) {
    writeln(b ? "YES" : "NO");
}

T[] readArr(T)() {
    return readln.split.to!(T[]);
}

T[] readArrByLines(T)(int n) {
    return iota(n).map!(i => readln.chomp.to!T).array;
}

void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}
