#include<bits/stdc++.h>
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long n, k;
    cin >> n >> k;
    vector<long long> v(k), d(k), s(k);
    map<long long, long long> m;
    for (long long i = 0; i < k; i++){
        cin >> v[i];
        m[v[i]] = i;
    }
    sort(v.begin(), v.end());
    d[0] = v[0];
    for (long long i = 1; i < k; i++){
        d[i] = d[0] ^ v[i];
    }
    for (long long i = 0; i < k; i++){
        s[m[v[i]]] = d[i];
    }
    for (long long i = 0; i < k; i++){
        cout << s[i] << " ";
    }
    return 0;
}