#include #define rep(i,l,r) for (int i=l;i<=r;i++) using namespace std; typedef long long ll; int b[105],c[105]; int tt; ll n; int main(){ // freopen("out.txt","w",stdout); // a[1]=1; // rep(i,2,100){ // rep(j,1,i-1) (a[i]+=a[j]*j)%=i; // } // rep(i,1,100) printf("%d\n",a[i]); // rep(i,1,100) printf("%d %d\n",i,i-a[i]); b[1]=0; b[2]=1; b[3]=3; b[4]=1; b[5]=5; b[6]=3; b[7]=2; b[8]=4; b[9]=8; c[0]=0; c[1]=5; c[2]=3; c[3]=2; c[4]=3; c[5]=5; scanf("%d",&tt); while (tt--){ scanf("%lld",&n); if (n<=9) printf("%lld\n",n-b[n]); else { n-=4; ll x=n%6; ll y=n/6; ll ans=b[x+4]+y*c[x]; //printf("%lld\n",ans); printf("%lld\n",n+4-ans); } } return 0; }