#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = LLONG_MAX;
const long long MINF = LLONG_MIN;
const int N = 1e5 + 5;
template <typename T>
inline T abs(T x) {
  return x < 0 ? -x : x;
}
inline long long pow_mod(long long x, long long n) {
  long long r = 1;
  while (n) {
    if (n % 2) r = (r * x) % MOD;
    x = (x * x) % MOD;
    n /= 2;
  }
  return r;
}
inline long long pow_(long long x, long long n) {
  long long r = 1;
  while (n) {
    if (n % 2) r = (r * x);
    x = (x * x);
    n /= 2;
  }
  return r;
}
bool isPrime(long long n) {
  if (n <= 3) return 1;
  if (n % 2 == 0 || n % 3 == 0) return 0;
  long long lim = sqrt(n);
  int i;
  for (i = 5; i <= lim; i += 6)
    if (n % i == 0 || n % (i + 2) == 0) return 0;
  return 1;
}
inline void solve() {
  long long n;
  cin >> n;
  long long ans = (n % 2), temp = 0, nn = n;
  n -= ans;
  int f = 1;
  while (n) {
    if (f) {
      if (n == 4 || (n % 2 == 0 && (n / 2) % 2 == 1))
        temp += (n /= 2);
      else
        temp++, n--;
    } else
      n--;
    f ^= 1;
  }
  if (ans)
    ans += nn - 1 - temp;
  else
    ans = temp;
  cout << ans << '\n';
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int t = 1;
  cin >> t;
  while (t--) solve();
}
