using System;

class Program
{
    static void Main()
    {
        string[] S= Console.ReadLine().Split();
        int brDelioca = int.Parse(S[1]);

        string[] s2 = Console.ReadLine().Split();
        long[] delioci = new long[brDelioca];

        for (int i = 0; i < brDelioca; i++)
        {
            delioci[i] = long.Parse(s2[i]);
        }

        for (int i = 0; i < brDelioca; i++)
        {
            long temp = 0;
            for (int j = 0; j < brDelioca; j++)
            {
                if (delioci[i] % delioci[j] == 0)  temp = temp ^ delioci[j]*2;
                    
            }

            Console.Write(temp + " ");
        }

        Console.WriteLine();
    }
}