#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

int xor_div(int i, const vector<int> & pdivs);

int main()
{
    int n;
    int k;
    cin >> n;
    cin >> k;
    vector<int> divisors;
    map<int, int> index_map;
    for(int i = 0; i < k; i++)
    {
        int tmp;
        cin >> tmp;
        divisors.push_back(tmp);
        index_map[tmp] = i;
    }

    // sort(divisors.begin(), divisors.end());
    int* to_print = new int[n];
    for(auto td : divisors)
    {
        int r = xor_div(td, divisors);
        cout << r << " ";
        //int idx = index_map[r];
        //to_print[idx] = r;
    }
    for(int i = 0; i < k; i++)
    {
        // cout << to_print[i] << " ";
    }
    cout << endl;
    return 0;
}

int xor_div(int i, const vector<int> & pdivs)
{
    int to_div = i;
    vector<int> divisrs;
    for(auto td : pdivs)
    {
        if(td > to_div)
        {
            //break;
        }
        if(to_div % td == 0)
            divisrs.push_back(td);
    }
    int res = 0;
    for(auto td : divisrs)
    {
        res ^= td;
    }
    return res;
}