#include <bits/stdc++.h>

using namespace std;

int main()
{
    long long n;
    int k;
    cin >> n >> k;
    vector<int> del(k);
    vector<int> ans(k);
    for (int i = 0; i < k; i++)
    {
        cin >> del[i];
        int c = 1;
        while (c * c < del[i])
        {
            if(del[i] % c ==0) ans[i] = (int)(ans[i] ^ c ^ del[i] / c);
            c++;
        }
        if(c * c == del[i]) ans[i] = (int)(ans[i] ^ c);
    }
    for(int i = 0; i < k; i++)
    {
        cout << ans[i] << " ";
    }
}