#include #define cir(x) memset(x,0,sizeof(x)) #define LL long long using namespace std; int main(){ int T; LL ans,n; LL k,t; scanf("%d",&T); while(T--){ scanf("%I64d",&n); k = n / 6; t = n % 6; if(n == 1){ printf("1\n"); continue; } if(t == 0){ printf("%I64d\n",(3 * k) % n); }else if(t == 1){ printf("%I64d\n",(4 * k + 1) % n); }else if(t == 2){ printf("%I64d\n",(3 * k + 1) % n); }else if(t == 3){ printf("%I64d\n",k % n); }else if(t == 4){ printf("%I64d\n",(6 * k + 3) % n); }else if(t == 5){ printf("%I64d\n",k % n); } } return 0; }