using System;
class Program
{
    static int xor_delilaca(int x)
    {
        int[] delioci = new int[x];
        int br = 0;
        for (int i = 1; i <= x; i++)
        {
            if (x % i == 0)
            {
                delioci[br] = i;
                br++;
            }
        }
        int xor = delioci[0];
        for (int i = 1; i <= delioci.Length - 1; i++)
            xor = xor ^ delioci[i];
        return xor;
    }
    static void Main(string[] args)
    {
        string[] unos = Console.ReadLine().Split();
        string[] unos2 = Console.ReadLine().Split();
        int n = Convert.ToInt32(unos[0]);
        int k = Convert.ToInt32(unos[1]);
        int[] niz = new int[k];
        for (int i = 0; i < k; i++)
            niz[i] = Convert.ToInt32(unos2[i]);
        for (int i = 0; i < niz.Length; i++)
            Console.Write(xor_delilaca(niz[i])+" ");
    }
}