#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll n, k;
vector<ll> a;
ll val(ll x){
    ll ans=1;
    vector<ll> del;
    for (ll i=2;(i*i)<=x;i++){
        if (x%i!=0) continue;
        del.push_back(i);
        if ((x/i)!=i) del.push_back((x/i));
    }
    for (ll i:del) {/*cout << ans << " " ;*/ans=(ans^i);}
    if (x!=1) ans=(ans^x);
    return ans;
}
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin >> n >> k;
    for (ll i=0;i<k;i++){
        ll x; cin >> x;
        a.push_back(x);
    }
    for (ll i=0;i<k;i++) cout << val(a[i]) << " ";
    return 0;
}