#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<ll> vi;

#define N 100007

ll c[N];
ll d[N];

ll nije_nzd(ll a, ll k) {
    ll proizvod = 1;
    for (ll i = 1; i < k; i++) {
        if (a % c[i] == 0) {
            proizvod = proizvod ^ c[i];
        }
    }
    return proizvod;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    unordered_map<ll, ll> erej;

    ll n;
    ll k;
    cin >> n >> k;

    for (ll i = 0; i < k; i++) {
        cin >> d[i];
        c[i] = d[i];
    }

    sort(c, c+k);

    for (ll i = 0; i < k; i++) {
        erej[c[i]] = nije_nzd(c[i], k);
    }
    for (ll i = 0; i < k; i++) {
        cout << erej[d[i]] << ' ';
    }

}