#include <bits/stdc++.h>
using ll=long long;
using namespace std;
void delioci (vector<ll> v,vector<ll> &del, ll n){
    ll j=0;
    for(ll i=0; i<v.size(); i++){
        if (n%v[i]==0) {del[j]=v[i]; j++;}
    }
}
ll XOr(vector<ll> v){
    ll X=v[0];
    for (ll i=1;i<v.size();i++){
        X=X^v[i];
    }
    return X;
}
int main()
{
    ll n, k;
    cin>>n>>k;
    vector<ll>r(k);
    vector<ll> v(k);
    ll j=0;
    for (ll i=0;i<k; i++){
        cin>>v[i];

    }
    for (int i=0;i<k;i++){
        vector<ll> del(k);
        delioci(v,del,v[i]);
        r[j]=XOr(del);
        j++;
    }
    for (int i=0;i<k;i++){
        cout<<r[i]<<" ";
    }
}