using System; using static System.Console; using System.Linq; using System.Collections.Generic; class Program { static int NN => int.Parse(ReadLine()); static int[] NList => ReadLine().Split().Select(int.Parse).ToArray(); static int[][] NArr(long n) => Enumerable.Repeat(0, (int)n).Select(_ => NList).ToArray(); public static void Main() { Solve(); } static void Solve() { var c = NList; var (n, x) = (c[0], c[1]); WriteLine(string.Join("\n", Divide(n, x))); } static List Divide(int n, int x) { if (n > 50000) { var s1 = DivideInt(100005 - n, x ^ 1); var ans = new List(); for (var i = 1; i <= 100005; ++i) if (!s1.Contains(i)) ans.Add(i); return ans; } else { return DivideInt(n, x).ToList(); } } static HashSet DivideInt(int n, int x) { var ans = new HashSet(); var rest = x; for (var i = 1; i < n; ++i) { ans.Add(i); rest ^= i; } if (rest >= 100006) { ans.Add(rest ^ 32768); if (n <= 32768) { ans.Remove(n - 1); ans.Add((n - 1) ^ 32768); } else { ans.Remove(32767); ans.Add(65535); } } else if (rest == 0) { ans.Add(65536); ans.Remove(1); ans.Add(65537); } else if (rest == 1) { if (ans.Contains(1)) { ans.Add(65537); ans.Remove(2); ans.Add(65538); } else { ans.Add(1); } } else if (rest < n) { if ((rest ^ 65536) > 100005) { ans.Add(rest ^ 98304); ans.Remove(1); ans.Add(98305); } else { ans.Add(rest ^ 65536); ans.Remove(1); ans.Add(65537); } } else ans.Add(rest); return ans; } class Info { public int L; public int R; public int U; public Info(int l, int r, int u = 0) { L = l; R = r; U = u; } } }