#include <iostream>
#include <bits/stdc++.h>
using namespace std;
vector<int_fast32_t>delioci(int a)
{
    vector<int_fast32_t>pom;
    for(int i =1;i<a/2;i++)
    {
        if(a%i==0)
            {
                pom.push_back(i);
                pom.push_back(a/i);
            }
    }
    return pom;
}
int ksordelilaca(vector<int_fast32_t>delilici)
{
    int ksor=delilici[0]^delilici[1];
    for(int_fast32_t i = 2;i<delilici.size();i++)
        ksor=ksor^delilici[i];
    return ksor;

}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int_fast32_t a,n,pom;
    cin>>a;
    cin>>n;
    vector<int_fast32_t>delilici;
    for(int_fast32_t i = 0; i<n;i++)
    {
        cin>>pom;
        delilici.push_back(pom);
    }
    for(int_fast32_t i = 0; i<n;i++)
    {
        cout<<ksordelilaca(delioci(delilici[i]))<<" ";
    }
}