using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;

namespace AtCoder
{
    class Program
    {

        static void Main(string[] args)
        {
            new Program().Solve();
        }

        public void Solve()
        {
            var sc = new Scanner();
            int M = sc.NextInt();
            int K = sc.NextInt();

            int length = 1 << M;
            int max = length - 1;

            int[] ans = new int[length * 2];

            // 使える値は1 ~ maxまで
            // xorがmaxを超えることはない
            if (K > max)
            {
                Console.WriteLine(-1);
                return;
            }

            // M >= 2のとき
            // 0 ~ 2^M-1の全部のxorは0になる
            // 0 ~ maxを順列A,Bに分けて AのxorがKになるようにするとBのxorもKになる
            // 選び方として簡単なのはK <= maxなので　A = {K} Bはそれ以外 
            if (M >= 2)
            {
                List<int> a = new List<int>();
                List<int> b = new List<int>();
                for (int i = 0; i <= max; i++)
                {
                    if (i == K)
                    {
                        a.Add(i);
                    }
                    else
                    {
                        b.Add(i);
                    }
                }

                // A B Aの逆順 Bの逆順と並べればOK
                for (int i = 0; i < a.Count; i++)
                {
                    ans[i] = a[i];
                    ans[i + a.Count + b.Count] = a[a.Count + ~i];
                }

                for (int i = 0; i < b.Count; i++)
                {
                    ans[i + a.Count] = b[i];
                    ans[i + a.Count + b.Count + a.Count] = b[b.Count + ~i];
                }
                Console.WriteLine(string.Join(" ", ans.ToArray()));
            }
            else
            {
                // それ以外のとき
                // 数が少ないので全部調べる
                // M == 0のとき
                // Kは0のときのみOK
                if (M == 0)
                {
                    if (K == 0)
                    {
                        Console.WriteLine("0 0");
                        return;
                    }
                    else
                    {
                        Console.WriteLine(-1);
                        return;
                    }
                }
                else if(M == 1)
                {
                    // M == 1のとき
                    // Kの候補は0, 1
                    // Kは0のみOK
                    if (K == 0)
                    {
                        Console.WriteLine("0 0 1 1");
                        return;
                    }
                    else
                    {
                        Console.WriteLine(-1);
                        return;
                    }
                }
            }
        }
    }
}

class Scanner
{
    public Scanner()
    {
        _stream = new StreamReader(Console.OpenStandardInput());
        _pos = 0;
        _line = new string[0];
    }

    const char Separator = ' ';
    private readonly StreamReader _stream;
    private int _pos;
    private string[] _line;

    #region スペース区切りで取得

    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = _stream.ReadLine().Split(Separator);
            _pos = 0;
        }

        return _line[_pos++];
    }

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

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

    public double NextDouble()
    {
        return double.Parse(Next());
    }

    #endregion

    #region 型変換

    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }

    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }

    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }

    #endregion

    #region 配列取得

    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = _stream.ReadLine().Split(Separator);

        _pos = _line.Length;
        return _line;
    }

    public int[] IntArray()
    {
        return ToIntArray(Array());
    }

    public long[] LongArray()
    {
        return ToLongArray(Array());
    }

    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }

    #endregion
}


Measured memory_bytes: 29400