using System;
using System.Collections.Generic;
using System.Linq;


namespace ConsoleApp4
{
    class Program
    {
        static List<long> Delioci(long n)
        {
            List<long> manji = new List<long>();
            List<long> veci = new List<long>();

        
            for (long i = 1; i * i <= n; i++)
            {
                if (n % i == 0)
                {
                    manji.Add(i);
                    long drugi = n / i;
                    if (drugi != i) veci.Add(drugi);
                }
            }

            veci.Reverse();
            manji.AddRange(veci);
            return manji;
        }

        static long Xor(List<long> d)
        {
            long x = 0;
            foreach (long a in d) x= x ^ a;
            return x;
        }
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split();
            long n = long.Parse(s[0]);
            long k = long.Parse(s[1]);
            List<long> d = new List<long>();
            string[] s1 = Console.ReadLine().Split();
            for(int i = 0; i < k; i++)
            {
                d.Add(long.Parse(s1[i]));
            }
            foreach(long delilac in d)
            {
                Console.Write(Xor(Delioci(delilac)) + " ");
            }


        }
    }
}