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] + 1, c[1]); var list = new List { new Info (0, 100006, n) }; var width = 65536; while (width > 0) { var nlist = new List(); foreach (var li in list) { nlist.Add(new Info(li.L, li.L + width )); nlist.Add(new Info(li.L + width, li.R )); } var xe = x / width % 2; var ue = 0; for (var i = 0; i < list.Count; ++i) { if (list[i].U == list[i].R - list[i].L) { nlist[i * 2].U = nlist[i * 2].R - nlist[i * 2].L; nlist[i * 2 + 1].U = nlist[i * 2 + 1].R - nlist[i * 2 + 1].L; ue += nlist[i * 2 + 1].U; } else { nlist[i * 2].U = Math.Min(nlist[i * 2].R - nlist[i * 2].L, list[i].U); nlist[i * 2 + 1].U = list[i].U - nlist[i * 2].U; ue += nlist[i * 2 + 1].U; } } ue %= 2; if (xe != ue) { for (var i = nlist.Count - 1; i >= 0; i -= 2) { if (nlist[i].U > 0 && nlist[i - 1].R - nlist[i - 1].L > nlist[i - 1].U) { --nlist[i].U; ++nlist[i - 1].U; break; } else if (nlist[i - 1].U > 0 && nlist[i].R - nlist[i].L > nlist[i].U) { --nlist[i - 1].U; ++nlist[i].U; break; } } } list = nlist; width >>= 1; } WriteLine(string.Join("\n", list.Where(li => li.L > 0 && li.U == 1).Select(li => li.L))); } 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; } } }