#include <bits/stdc++.h>
using ll=long long;
using namespace std;
void delioci (vector<ll> &del, ll n){
    ll j=0;
    for(ll i=1; i<n; i++){
        if (n%i==0) {del[j]=i; j++;}
    }
    del[j]=n;
}
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);
    ll j=0;
    for (ll i=0;i<k; i++){
        ll n;
        cin>>n;
        vector<ll> del(k);
        delioci(del,n);
        r[j]=XOr(del);
        j++;

    }
    for (int i=0;i<k;i++){
        cout<<r[i]<<" ";
    }

}