#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
ll N, K;
ll D[100005], DC[100005];
int P[10000006];
unordered_map<ll, ll> M;
ll gcd(ll a, ll b)
{
  if(!b)return a;
  return gcd(b, a % b);
}
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> N >> K;
  for(int i = 1; i <= K; i++)cin >> D[i], DC[i] = D[i];

  sort(D + 1, D + K + 1);
  for(int  i = 1; i <= K; i++)
  {
    for(int j = i; j <= K; j++)
    {

      if(D[j] % D[i] == 0)
        M[D[j]] ^= D[i];
    }
  }
  for(int i = 1; i <= K; i++)cout << M[DC[i]] << ' ';
  return 0;
}