#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<map>
#include<math.h>
#include<map>
#include<string>
using namespace std;
const int maxn=100020;
const int inf=0x3f3f3f;
int main(){
int t;
int n;
cin>>t;
while(t--){
cin>>n;
int mod=n%3;
int res=n/3;
res*=2;
if(mod==1) res+=1;
else if(mod==2) res+=2;
res%=3;
cout<<res<<endl;
}
}