#include <bits/stdc++.h>
#define ll long long
#define endl '\n'

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    ll N, K;
    cin >> N >> K;
    vector <ll> D(K);
    map <ll, ll> res;
    for(int i = 0; i < K; i++) cin >> D[i];
    for(int i = 0; i < K; i++)
    {
        ll num = D[i];
        for(int j = num; j <= N; j += num) res[j] ^= num;
    }
    for(int i = 0; i < K; i++) cout << res[D[i]] << " ";
    return 0;
}