#include <iostream>
#include <bits/stdc++.h>

using namespace std;
vector <long long> c;

int xor_delilaca (long long n, long long k)
{
    if(n == 1)
        return 1;

    long long sum = 1;
    for(int i=1; i<k; i++)
    {
        if(c[i] == n)
        {
            sum = sum ^ c[i];
            break;
        }
        if(n % c[i] == 0)
            sum = sum ^ c[i];
    }

    return sum;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);

    long long n, k;
    cin>>n>>k;
    vector <long long> v(k);

    for(long long i=0; i<k; i++)
    {
        cin>>v[i];
        c.push_back(v[i]);
    }

    sort(c.begin(), c.end());

    for(long long i=0; i<k; i++)
    {
        long long res = xor_delilaca(v[i], k);

        cout << res << " ";
    }

    return 0;
}