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


    for(long long i = 1; i <= K; i++){
        Sol = 0;
        koef = (N / k[i]);
        for(long long j = 1; j <= K; j++){
            if(k[j] % koef == Nula){
                Sol = (Sol ^ (k[j] / koef));
            }
        }
        printf("%lld ", Sol);
    }

return 0;
}