#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 9;
const double ep = 1e-4;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const double pi = acos(-1);
long long n, res;
void solve() {
  res = 0;
  scanf("%lld", &(n));
  bool ju = 0;
  while (n) {
    if (n & 1) {
      if (!ju) res++;
      ju ^= 1;
      n--;
      continue;
    }
    if (n < 12) {
      if (!ju) res += n / 2;
      n /= 2;
      ju ^= 1;
      continue;
    }
    if (n % 4) {
      if (!ju) res += n / 2;
      n /= 2;
      ju ^= 1;
      continue;
    }
    if (!ju) res++;
    n--;
    ju ^= 1;
    continue;
  }
  printf("%lld\n", (res));
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int T = 1;
  scanf("%d", &(T));
  while (T--) solve();
}
