#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long t = 1;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long ans = 0;
    bool ok = true;
    while (n > 0) {
      if ((n & 1)) {
        if (ok) ans += 1;
        n -= 1;
      } else {
        if (n % 4 == 0 && (n / 4 > 2)) {
          if (ok) ans += 1;
          n -= 1;
        } else {
          if (ok) ans += n / 2;
          n /= 2;
        }
      }
      ok = !ok;
    }
    cout << ans << "\n";
  }
}
signed main() {
  solve();
  return 0;
}
