#include<stdio.h> #include<math.h> int main(){ int t; scanf("%d",&t); while(t--){ int n,result = 0,i; scanf("%d",&n); for(i = 1;i<=n;i++){ if(i%3){ result+=1; } } printf("%d\n",result%3); } }