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

bool Kvadrat(long long x) {
    long long r = llround(sqrt((long double)x));
    return r * r == x;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    long long N;
    int K;
    cin >> N >> K;

    vector<long long> d(K);
    for (int i = 0; i < K; i++) {
        cin >> d[i];
    }

    for (long long x : d) {
        if (x == 1) {
            cout << 1 << " ";
        } else if (Kvadrat(x)) {
            cout << 0 << " ";
        } else {
            cout << x << " ";
        }
    }

    cout << "\n";
    return 0;
}