#include <bits/stdc++.h>
using namespace std;
int N, K;
long long k[200005], Sol, koef;
int main(){
    scanf("%d%d", &N, &K);
    for(int i = 1; i <= K; i++){
        scanf("%lld", &k[i]);
    }


    for(int i = 1; i <= K; i++){
        Sol = 0;
        koef = (N / k[i]);
        for(int j = 1; j <= K; j++){
            if(k[j] % koef == 0){
                Sol = (Sol ^ (k[j] / koef));
            }
        }
        cout << Sol << " ";
    }
    cout << endl;

return 0;
}