#include<cstdio>
#include <algorithm>
#include <iostream>
#include<cstring>
#include<cmath>
using namespace std;
const int maxn=100005;
long long n,m,f[maxn],a[maxn];
int main()
{
for(long long i=1;i<=100005;i++)
{
if(i%3==1||i%3==2)
f[i]=1;
else if(i%3==0)
f[i]=0;
}
a[1]=1;
for(long long i=2;i<=100005;i++)
{
a[i]=(a[i-1]+f[i])%3;
}
int t;
scanf("%d",&t);
while(t--)
{
scanf("%lld",&n);
printf("%d\n",a[n]);
}
// system("pause");
}