#include <bits/stdc++.h>
using namespace std;
using ll=long long;
void generisi_delioce(ll x, vector<ll>& del){
    ll s=sqrt(x);
    for(ll i=1; i<=s; i++){
        if(x%i==0){
            del.push_back(i);
            if(i!=x/i) del.push_back(x/i);
        }
    }
}
ll xor_d(ll x){
    ll nijevisevasa=0;
    vector<ll> del;
    generisi_delioce(x,del);
    ll n=del.size();
    for(ll i=0; i<n; i++){
        nijevisevasa^=del[i];
    }
    return nijevisevasa;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,k;
    cin>>n>>k;
    vector<ll> d(k);
    for(ll i=0; i<k; i++) cin>>d[i];
    for(ll i=0; i<k; i++){
       cout<<xor_d(d[i])<<" ";
    }
}