#include<bits/stdc++.h>
using namespace std;
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    vector<short> sq;
    for (short i = 1; i*i < 500000; i++) {
        sq.push_back(i*i);
    }
    bool b;
    short n;
    cin >> n;
    vector<short> a(n);
    for (short i = 0; i < n; i++) {
        cin >> a[i];
        b = 0;
        for (short j = 0; j < sq.size() && sq[j] < a[i]; j++) {
            short l = 0, r = sq.size()-1;
            while (l < r-1) {
                short x = l + (r-l)/2;
                if (sq[x]+sq[j] > a[i]) {
                    r = x;
                }
                else if (sq[x]+sq[j] < a[i]) {
                    l = x;
                }
                else {
                    b = 1;
                    break;
                }
            }
            if (b == 1) {
                break;
            }
        }
        cout << b;
    }
    return 0;
}
