#include<bits/stdc++.h>
using namespace std;
const int MAXN=10;
bitset<MAXN> ans;
inline int read()
{
int x=0,f=1;char ch=getchar();
while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=getchar();}
while (ch>='0'&&ch<='9'){x=x*10+ch-48;ch=getchar();}
return x*f;
}
inline void write(int x)
{
if(x<0)
{
putchar('-');
x=-x;
}
if(x>9)
write(x/10);
putchar(x%10+'0');
}
int main(){
int cnt=0;
ans.reset();
for(int i=0;i<MAXN;i+=cnt){
ans[i]=1;
cnt++;
}
int n;
n=read();
while(n--){
int i;
i=read();i-=1;
write(ans[i]);
puts("");
}
return 0;
}