#include<stdio.h> #include<string.h> int main() { int n; scanf("%d",&n); while(n--) { int m,a,b,c; scanf("%d",&m); a=m/3; b=m%3; c=a*2+b; c%=3; printf("%d\n",c%3); } return 0; }