#include<stdio.h> int main(void) { int t,x,m; scanf("%d",&t); while(t--) { scanf("%d",&x); m=x/3; printf("%d\n",(x-m)%3); } return 0; }