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

int n, arr[50000], k, j;

int main()
{
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        cin >> arr[i];
    }
    for(int i = 0; i < n; i++)
    {
        bool flag = true;
        for(j = 1; j*j < arr[i]; j++)
        {
            for(k = 1; k*k <= arr[i] && j*j+k*k != arr[i]; k++);
        }
        if(k*k > arr[i]) cout << "0";
        else cout << "1";
    }
    return 0;
}
