#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
const long long MAXN = 2e5 + 10;
const long long INF = 1e9;
const long long mod = 1e9 + 7;
const long double eps = 1e-5;
using namespace std;
long long _n;
long long solve1(int tt) {
  long long n = _n;
  long long p[2];
  p[0] = p[1] = 0;
  long long l = 1;
  while (l <= n) l *= 2;
  l /= 2;
  long long q = n - l;
  p[0] = (q + 1) / 2;
  p[1] = (q) / 2;
  int t = (q % 2 == 0 ? 0 : 1);
  p[t] += 1;
  t ^= 1;
  q = l - 1;
  while (q) {
    long long r = (q % 2 == 0 ? q / 2 : 1);
    p[t] += r;
    q -= r;
    t ^= 1;
  }
  return p[0];
}
long long solve2(int tt) {
  long long n = _n;
  long long p[2];
  p[0] = p[1] = 0;
  int t = 0;
  while (n) {
    long long q = (n % 2 == 0 ? n / 2 : 1);
    p[t] += q;
    n -= q;
    t ^= 1;
  }
  return p[0];
}
long long make_turn(long long& n) {
  if (n % 2 == 1) {
    n--;
    return 1;
  }
  if ((n & 2) == 0 && n > 4) {
    n--;
    return 1;
  }
  n /= 2;
  return n;
}
long long solve3(int tt) {
  long long ans = 0;
  long long n = _n;
  while (n) {
    ans += make_turn(n);
    if (n > 0) make_turn(n);
  }
  return ans;
}
int main() {
  srand(time(NULL));
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  t = 1;
  cin >> t;
  for (int i = 0; i < t; i++) {
    cin >> _n;
    cout << solve3(0) << endl;
  }
  return 0;
}
