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

int findTrue(int q)
{
    for(int j = 1; j*j < q; j++)
    {
        int goal = q-j*j, maxVal = 707, minVal = 1, guess = 354;
        while(guess*guess != goal && minVal != maxVal && maxVal > minVal)
        {
            if(guess*guess < goal)
            {
                minVal = guess+1;
            }
            if(guess*guess > goal)
            {
                maxVal = guess-1;
            }
            guess = (minVal+maxVal)/2;
        }
        if(guess*guess == goal)
        {
            return 1;
        }
    }
    return 0;
}

int main()
{
    int n;
    cin>>n;
    int q;
    for(int i = 0; i < n; i++)
    {
        cin>>q;
        cout<<findTrue(q);
    }
    return 0;
}
