#include <bits/stdc++.h>

using namespace std;

unsigned long long int Xordel(vector<unsigned long long int> d,
            unsigned long long int x, unsigned long long int b)
{
    for(auto a:d)
        if(a > 1 && x % a != 0LL)
            b ^= a;
    return b;
}

int main()
{
    int k;
    unsigned long long int n;
    cin >> n >> k;
    vector<unsigned long long int> d(k, 0LL);
    for(int i = 0; i < k; i++)
        cin >> d[i];

    unsigned long long int a = 1LL;
    for(auto x:d)
    {
        if(x==1)
            continue;
        a ^= x;
    }
    cout << a;

    for(int i = 0; i < k; i++)
    {
        if(d[i] == n)
            continue;
        cout << " " << Xordel(d, d[i], a);
    }
    return 0;
}