#include <bits/stdc++.h>
using namespace std;
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
int cansel_sync = (ios::sync_with_stdio(0), cin.tie(0), 0);
const int N = 200010;
const int inf = ~0u >> 2;
const long long INF = ~0ull >> 2;
long long read() {
  long long x;
  if (scanf("%lld", &x) == -1) exit(0);
  return x;
}
const double pi = acos(-1.0);
double readf() {
  double x;
  if (scanf("%lf", &x) == -1) exit(0);
  return x;
}
template <typename T>
void operator<<(vector<T> &a, T b) {
  a.push_back(b);
}
const long long mod = (1 ? 1000000007 : 998244353);
long long mul(long long a, long long b, long long m = mod) { return a * b % m; }
long long qpow(long long a, long long b, long long m = mod) {
  long long ans = 1;
  for (; b; a = mul(a, a, m), b >>= 1)
    if (b & 1) ans = mul(ans, a, m);
  return ans;
}
void Solve() {
  long long n = read(), a = 0;
  if (n % 2 == 0) {
    while (n) {
      if (n == 4) {
        a += 3;
        break;
      }
      if (n % 4 == 0) {
        n -= 2;
        a++;
      } else if (n % 4 == 2) {
        a += n / 2;
        n /= 2;
        n--;
      }
    }
    cout << a << endl;
  } else {
    long long nn = n;
    n--;
    while (n) {
      if (n == 4) {
        a += 3;
        break;
      }
      if (n % 4 == 0) {
        n -= 2;
        a++;
      } else if (n % 4 == 2) {
        a += n / 2;
        n /= 2;
        n--;
      }
    }
    cout << nn - a << endl;
  }
}
signed main() {
  long long T = 1;
  T = read();
  for (long long ca = (1), _ = (T + 1); ca < _; ca++) {
    Solve();
  }
  return 0;
}
