using System;

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

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

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

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

            Console.Write(temp + " ");
        }
       
    }
}