#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define endl "\n"
///freopen("input.txt", "r", stdin);
///freopen("output.txt", "w", stdout);
void solve(){
    int n,k;
    cin>>n>>k;

    vector<int>del(k);
    for(int i=0;i<k;i++)cin>>del[i];

    vector<int>a=del;

    sort(del.begin(),del.end());

    map<int,int>mapa;
    vector<int>ans(k,1);
    for(int i=1;i<k;i++){
        mapa[del[i]]=i;
        int rez=1;
        for(int j=1;j<i;j++){
            if(del[i]%del[j]==0){
                rez^=del[j];
            }
        }
        //cout<<rez<<" ";
        ans[i]=rez;
    }
    ///cout<<endl;


    for(int i=0;i<k;i++){
        int broj=a[i];
        int poz=mapa[broj];

        cout<<ans[poz]<<" ";
    }cout<<endl;
}
signed main(){
    ios_base::sync_with_stdio(false);cin.tie(0);
    int t=1;///cin>>t;
    while(t--)solve();
    return 0;
}