#include <bits/stdc++.h>
using namespace std;
long long int solve(long long int coin);
int main() {
  long long int testCases;
  cin >> testCases;
  long long int coin[testCases];
  for (long long int i = 0; i < testCases; i++) {
    cin >> coin[i];
  }
  for (long long int i = 0; i < testCases; i++) {
    cout << solve(coin[i]) << endl;
  }
}
long long int solve(long long int coin) {
  if (coin < 5) {
    return max(1ll, coin - 1);
  } else {
    if (coin % 2 == 1 or coin % 4 == 0) {
      return coin - solve(coin - 1);
    } else {
      return coin - solve(coin / 2);
    }
  }
}
