#include<bits/stdc++.h>
using namespace std;
using ll=long long;

#pragma GCC optimize("O3")
const ll N=1e5+555;
ll a[N],n,k;

signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0);

    cin>>n>>k;
    for(int i=1;i<=k;++i){
        cin>>a[i];
        ll ans=0;
        for(ll j=1;j*j<=a[i];++j){
            if(a[i]%j)continue;
            ans^=j;
            if(j*j!=a[i])ans^=(a[i]/j);
        }
        cout<<ans<<' ';
    }
}