#pragma GCC optimize("O3") #pragma GCC target("avx,avx2,fma") #include #define endl '\n' using namespace std; void SolveTestcase() { int64_t N; cin >> N; int64_t L = 1, R = N, distanceBetweemBiscuits = 1, total = N; bool step = 0; while (total != 1) { if (step == 0) { if (total%2 == 0) { R -= distanceBetweemBiscuits; } } else { if (total%2 == 0) { L += distanceBetweemBiscuits; } } step ^= 1; distanceBetweemBiscuits *= 2; total = (total+1)/2; } cout << L << endl; } int main() { #ifndef __LOCAL__ freopen("biscuits.in", "r", stdin); freopen("biscuits.out", "w", stdout); #endif // __LOCAL__ int T; cin >> T; while (T--) { SolveTestcase(); } return 0; }