#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define ll long long
#define ld long double
#define mp make_pair
const int N=1e5+50;
ll _n;int n;
ll a[N];
pair<ll,int>Qs[N];
ll res[N];
vector<ll>primes;
int main(){
    scanf("%lld%i",&_n,&n);
    for(int i=1;i<=n;i++)scanf("%i",&a[i]);
    for(int i=1;i<=n;i++)Qs[i]={a[i],i};
    sort(Qs+1,Qs+n+1);
    sort(a+1,a+n+1);
    for(int i=2;i<=n;i++){
        bool moze=true;
        for(auto p:primes){
            if(a[i]%p==0)moze=false;
        }
        if(moze)primes.pb(a[i]);
    }
    //for(auto i:primes) printf("%i ",i);printf("\n");
    for(int i=1;i<=n;i++){
        ll x=a[i];
        vector<ll>dvs={1};
        for(auto p:primes){
            int vp=0;
            while(x%p==0){x/=p;vp++;}
            int m=dvs.size();
            for(int k=1,P=p;k<=vp;k++,P*=p){
                for(int j=0;j<m;j++){
                    dvs.pb(dvs[j]*P);
                }
            }
        }
        for(auto j:dvs)res[Qs[i].se]^=j;
    }
    for(int i=1;i<=n;i++)printf("%lld ",res[i]);printf("\n");
    return 0;
}