using System;
using System.Collections.Generic;
using System.Reflection.Metadata.Ecma335;

class Program
{
    static void Main()
    {
        string[] ss = Console.ReadLine().Split();
        long n = long.Parse(ss[0]);
        long k = long.Parse(ss[1]);

        long[] d = new long[k];
        long[] res = new long[k];

        ss = Console.ReadLine().Split();
        for (int i = 0; i < k; i++)
            d[i] = long.Parse(ss[i]);

        for (int i = 0; i < k; i++)
        {
            for (int j = 0; j < k; j++)
            {
                if (d[i] % d[j] == 0)
                {
                    res[i] ^= d[j];
                }
            }
        }

        for (int i = 0; i < k; i++)
            Console.Write(res[i]+" ");


    }
    static List<long> Deviders(long n, long a)
    {
        long temp = a;
        List<long> array = new List<long>();
        array.Add(1);
        bool visited = false;
        long dx = 2;
        for(long i = dx; i*i <= n; i++)
        {
            if (a == 1) break;
            while (a % dx == 0)
            {
                if(!visited)
                    array.Add(i);
                a /= dx;
                visited= true;
            }
            visited = false;
            dx++;
        }
        if (a != 1) 
            array.Add(a);
        array.Add(temp);
        return array;
    }
}