/*
csc -debug F.cs && mono --debug F.exe <<< "1 1"
*/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Reflection;

public class HelloWorld {
    public static void SolveCodeForces() {
        var M = cin.NextInt();
        var K = cin.NextInt();

        var n = 1;
        for (var i = 0; i < M; i++) n *= 2;

        if (K == 0) {
            var ans = new int[2*n];
            for (var i = 0; i < ans.Length; i++) {
                ans[i] = i / 2;
            }
            System.Console.WriteLine(string.Join(" ", ans));
            return;
        }

        if (n % 4 != 0 || K >= n) {
            System.Console.WriteLine(-1);
            return;
        }

        {
            var ans = new List<int>(2*n);
            for (var i = 0; i < n; i++)
                if (i != K)
                    ans.Add(i);

            ans.Add(K);

            for (var i = n-1; i >= 0; i--)
                if (i != K)
                    ans.Add(i);

            ans.Add(K);

            System.Console.WriteLine(string.Join(" ", ans));

// System.Console.WriteLine(new {M, K, n, sum=AllEq(ans.ToArray())});
        }

        // var A = cin.IntArray();
        // System.Console.WriteLine(AllEq(A));
        // Find();

        // for (var lim = 1; lim <= 32; lim++) {
        //     var sum = 0;
        //     for (var i = 0; i < lim; i++)
        //         sum ^= i;
        //     System.Console.WriteLine(new {lim, sum});
        // }
    }

    static void Find() {
        var rnd = new Random(123);
        const int N = 12;

        var hash = new HashSet<string>();
        var differentK = new HashSet<int>();

        for (var t = 0; t < 100000; t++) {
            var A = Helpers.CreateArray(N, i => i);
            A.ShuffleInPlace(rnd);
            var B = Helpers.CreateArray(N, i => i);
            B.ShuffleInPlace(rnd);
            var C = A.Concat(B).ToArray();
            var k = AllEq(C);
            if (k > 0) {
                // System.Console.WriteLine(new {arr=string.Join(" ", C), k});
                hash.Add(string.Join(" ", C) + "; " + k);
                differentK.Add(k);
            }
        }

        foreach (var str in hash.OrderBy(s => s).Take(10))
            System.Console.WriteLine(str);

        System.Console.WriteLine();
        System.Console.WriteLine("Different K: " + string.Join(" ", differentK));
    }

    static int AllEq(int[] arr) {
        var indexes = Helpers.CreateArray(arr.Length/2, _ => new int[2] { int.MaxValue, -1 });
        for (var i = 0; i < arr.Length; i++) {
            var curr = indexes[arr[i]];
            curr[0] = Math.Min(curr[0], i);
            curr[1] = Math.Max(curr[1], i);
        }

        var xors = new int[arr.Length+1];
        for (var i = 0; i < arr.Length; i++)
            xors[i+1] = xors[i] ^ arr[i];

        var k = xors[indexes[0][0]] ^ xors[indexes[0][1]+1];
        for (var i = 1; i < indexes.Length; i++) {
            var sum = xors[indexes[i][0]] ^ xors[indexes[i][1]+1];
            if (sum != k)
                return -1;
        }
        return k;

        // for (var i = 0; i < indexes.Length; i++)
        //     System.Console.WriteLine(new {i, indexes=string.Join(" ", indexes[i]), sum = xors[indexes[i][0]] ^ xors[indexes[i][1]+1]});
        // return 42;
    }

    static Scanner cin = new Scanner();
    static StringBuilder cout = new StringBuilder();

    static public void Main () {
        SolveCodeForces();
        // IncreaseStack(SolveCodeForces);
        // System.Console.Write(cout.ToString());
    }

    public static void IncreaseStack(ThreadStart action, int stackSize = 128000000)
    {
        var thread = new Thread(action, stackSize);
        thread.Start();
        thread.Join();
    }
}

public static class Helpers {
    public static T[] CreateArray<T>(int length, Func<int, T> itemCreate) {
        var result = new T[length];
        for (var i = 0; i < result.Length; i++)
            result[i] = itemCreate(i);
        return result;
    }

    public static IList<T> ShuffleInPlace<T>(this IList<T> list, Random rnd)
    {
        int n = list.Count;
        while (n > 1) {
            n--;
            int k = rnd.Next(n + 1);
            var value = list[k];
            list[k] = list[n];
            list[n] = value;
        }
        return list;
    }
}

public class Scanner
{
    private string[] line = new string[0];
    private int index = 0;

    public string Next() {
        if (line.Length <= index) {
            line = Console.ReadLine().Split(' ');
            index = 0;
        }
        var res = line[index];
        index++;
        return res;
    }

    public int NextInt() {
        return int.Parse(Next());
    }

    public long NextLong() {
        return long.Parse(Next());
    }

    public ulong NextUlong() {
        return ulong.Parse(Next());
    }

    public string[] Array() {
        line = Console.ReadLine().Split(' ');
        index = line.Length;
        return line;
    }

    public int[] IntArray(int emptyPrefixLen = 0) {
        var array = Array();
        var result = new int[emptyPrefixLen + array.Length];
        for (int i = 0; i < array.Length; i++)
            result[emptyPrefixLen + i] = int.Parse(array[i]);
        return result;
    }

    public long[] LongArray() {
        var array = Array();
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
            result[i] = long.Parse(array[i]);
        return result;
    }

    public ulong[] UlongArray() {
        var array = Array();
        var result = new ulong[array.Length];
        for (int i = 0; i < array.Length; i++)
            result[i] = ulong.Parse(array[i]);
        return result;
    }
}

Measured memory_bytes: 29272