#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
using namespace std;
long long MOD = 1000000009;
double eps = 1e-12;
void solve() {
  long long n;
  cin >> n;
  long long i = 0;
  long long ans = 0;
  while (n > 0) {
    long long k;
    if ((n % 2 == 0 && (n / 2) % 2 == 1) || n == 4) {
      k = n / 2;
      n /= 2;
    } else {
      n--;
      k = 1;
    }
    if (i % 2 == 0) {
      ans += k;
    }
    i++;
  }
  cout << ans << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t;
  cin >> t;
  for (int it = 1; it <= t; it++) {
    solve();
  }
  return 0;
}
