#include <bits/stdc++.h>

using namespace std;

unsigned long long int Xordel(unsigned long long int d)
{
    unsigned long long int x = 1LL;
    unsigned long long int i;
    for(i = 2LL; i * i < d; i++)
    {
        if(d % i == 0LL)
        {
            x ^= i;
            x ^= d / i;
        }
    }
    if(i*i == d)
        x ^= i;
    if(d > 1LL)
        x ^= d;
    return x;
}

int main()
{
    int k;
    unsigned long long int n;
    cin >> n >> k;
    vector<unsigned long long int> d(k, 0LL);
    for(int i = 0; i < k; i++)
        cin >> d[i];
    for(auto x:d)
        cout << Xordel(x) << " ";
    return 0;
}