#include <bits/stdc++.h>
using namespace std;
void solve(long long int test) {
  long long int n = LONG_LONG_MAX;
  cin >> n;
  long long int a, b;
  a = b = 0;
  bool flag = true;
  while (n) {
    if (flag) {
      if (n % 2 || (n % 4 == 0 && n > 8))
        a++, n -= 1;
      else
        a += n / 2, n /= 2;
    } else {
      if (n % 2 || (n % 4 == 0 && n > 8))
        b++, n -= 1;
      else
        b += n / 2, n /= 2;
    }
    flag = (!flag);
  }
  cout << a << endl;
}
int main() {
  long long int t = 1, test = 1;
  cin >> t;
  while (t--) {
    solve(test++);
  }
  return 0;
}
