#include <iostream>
#include <vector>

using namespace std;

int xor_delilaca(const vector<int> &vec, const int &x)
{
    int val = 0;
    for (int i = 0; i < vec.size(); ++i)
      if (vec[i] <= x and x % vec[i] == 0)
      {
          val ^= vec[i];
          // cout << vec[i] << ' ';
      }
    
    return val;
}

int main(void)
{
    int n, k;
    cin >> n >> k;
    
    vector<int> d(k);
    for (int i = 0; i < k; ++i)
      cin >> d[i];
    
    for (int i = 0; i < k; ++i)
    {
        cout << xor_delilaca(d, d[i]) << ' ';
    }
    
    return 0;
}