#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using db = long double;
using str = string;

using pi = pair<int,int>;
using pl = pair<ll,ll>;
using pd = pair<db,db>;

using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<ll>;
using vd = vector<db>;
using vs = vector<str>;
using vpi = vector<pi>;
using vpl = vector<pl>;
using vpd = vector<pd>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using vvpi = vector<vpi>;

#define mp make_pair
#define f first
#define s second

#define sz(x) int((x).size())
#define bg(x) begin(x)
#define all(x) bg(x), end(x)
#define rall(x) x.rbegin(), x.rend()
#define sor(x) sort(all(x))
#define rsz resize
#define ins insert
#define ft front()
#define bk back()
#define pb push_back
#define eb emplace_back
#define pf push_front
#define er erase
#define ub upper_bound
#define lb lower_bound

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

const int MOD = 1e9+7; // 998244353;
const int MX = 2e5+5;
const ll INF = 1e18;
const db PI = acos((db)-1);
const int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;

template<typename T>
using indexed_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define ook order_of_key
#define fbo find_by_order

ll reshi(ll y, ll b, ll sol){
    ll c = 0;
    //ll bc = b, solc = sol;
    while(b){
        if(b % 2)c ^= sol;
        b /= 2;
        sol <<= 1LL;
    }
    //cerr << "reshi " << y << " " << bc << " " << solc << " " << c << endl;
    return c;
}

void solve(){
    ll n, k;
    cin >> n >> k;
    vl v(k);
    map<ll, int> ind;
    F0R(i, k){
        cin >> v[i];
        ind[v[i]] = i;
    }
    sor(v);
    //trav(el, v)cerr << el.f << " ";
    vl md(k, 1);
    FOR(i, 1, k){
        if(md[i] == 1){
            md[i] = v[i];
            FOR(j, i + 1, k){
                if(md[j] != 1 || (v[j] % v[i]))continue;
                md[j] = v[i];
            }
        }
    }
    //trav(el, md)cerr << el << " ";
    //cerr << endl;
    vl sol(k), sol2(k);
    sol[ind[1]] = sol2[ind[1]] = 1;
    FOR(i, 1, k){
        ll x = v[i], y = x;
        x /= md[i];
        ll b = 1;
        while(!(y % md[i])){
            y /= md[i];
            b *= md[i];
        }
        ll c = sol[ind[x]];
        //cerr << v[i] << " ";
        c ^= reshi(y, b, sol[ind[y]]);
        sol[ind[v[i]]] = c;
    }
    /*FOR(i, 1, k){
        F0R(j, i + 1){
            if(v[i] % v[j])continue;
            sol2[ind[v[i]]] ^= v[j];
        }
    }*/
    trav(el, sol)cout << el << " ";
    cout << endl;
    //trav(el, sol2)cout << el << " ";
    //cout << endl;
}

/*
12 6
12 1 3 6 2 4
72 12
1 2 3 4 6 8 9 12 18 24 36 72

*/

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t;
    t = 1;
    while(t--)solve();
}