#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),x.end()
#define fi first
#define sc second
#define pii pair<int,int>
#define endl "\n"

using namespace std;

int rez(int x)
{
    int xr = 0;
    for(int i=1; i<=sqrt(x); i++)
    {
        if(i*i == x)xr^=i;
        else if(x%i == 0)
        {
            xr^=i;
            xr^=(x/i);
        }
    }
    return xr;
}

signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n,k; cin >> n >> k;
    vector<pii> niz(k);
    for(int i=0; i<k; i++)cin >> niz[i].fi, niz[i].sc = i;
    //vector<int> rez(k);
    //sort(all(niz));
    for(int i=0; i<k; i++)cout << rez(niz[i].fi) << " ";cout << endl;

}