#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int tc = 1;
  cin >> tc;
  while (tc--) {
    long long n, res = 0;
    cin >> n;
    bool f = true;
    while (n) {
      if (f) {
        if ((n % 4 == 0 && n != 4) || n & 1)
          n--, res++;
        else
          n /= 2, res += n;
        f = !f;
      } else {
        if ((n % 4 == 0 && n > 8) || n % 2 == 1)
          n--;
        else
          n /= 2;
        f = !f;
      }
    }
    cout << res << "\n";
  }
  return 0;
}
