#include <bits/stdc++.h>
using namespace std;
int t;
long long n;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> t;
  while (t--) {
    cin >> n;
    bool potez = true;
    long long zbir = 0LL;
    while (n > 0) {
      if (n % 2LL != 0LL) {
        if (potez) zbir += 1LL;
        n -= 1LL;
      } else {
        if (n % 4LL != 0LL || n == 4LL) {
          if (potez) zbir += n / 2LL;
          n /= 2LL;
        } else {
          if (potez) zbir += 1LL;
          n -= 1LL;
        }
      }
      potez = !potez;
    }
    cout << zbir << endl;
  }
  return 0;
}
