#include <bits/stdc++.h>

using namespace std;

unsigned long long int Xordel(vector<unsigned long long int> d, unsigned long long int x)
{
    unsigned long long int b = 1LL;
    for(auto a:d)
        if(a > 1 && x % a == 0)
            b ^= a;
    return b;
}

int main()
{
    int k;
    unsigned long long int n;
    cin >> n >> k;
    vector<unsigned long long int> d(k, 0LL);
    for(int i = 0; i < k; i++)
        cin >> d[i];
    for(auto x:d)
        cout << Xordel(d, x) << " ";
    return 0;
}