#include <iostream>
#include <vector>
#include <cstdint>

using namespace std;

uint64_t xor_delilaca(const vector<uint64_t> &vec, const uint64_t &x)
{
    uint64_t val = 0;
    for (uint64_t 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)
{
    uint64_t n, k;
    cin >> n >> k;
    
    vector<uint64_t> d(k);
    for (uint64_t i = 0; i < k; ++i)
      cin >> d[i];
    
    for (uint64_t i = 0; i < k; ++i)
    {
        cout << xor_delilaca(d, d[i]) << ' ';
    }
    
    return 0;
}