#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
const int N = 1e5 + 5, M = N;
void solve() {
  long long n, m, res = 0;
  bool ok = 1;
  scanf("%lld", &n);
  while (n) {
    if (ok) {
      ok = 0;
      if (n % 2)
        res++, n -= 1;
      else {
        m = n / 2;
        if (m == 2 || m % 2)
          res += m, n /= 2;
        else
          res++, n--;
      }
    } else {
      ok = 1;
      if (n % 2)
        n -= 1;
      else {
        m = n / 2;
        if (m == 2 || m % 2)
          n /= 2;
        else
          n--;
      }
    }
  }
  printf("%lld\n", res);
}
int main() {
  int t = 1;
  scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}
