#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll N, K;
ll D[100001];
int main()
{
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> N >> K;
  for(int i = 1; i <= K; i++) cin >> D[i];
  for(int i = 1; i <= K; i++)
  {
    ll xr = 0;
    for(int j = 1; j <= K; j++) if(!(D[i] % D[j])) xr ^= D[j];
    cout << xr << " \n"[i == K];
  }

  return 0;
}