#include <bits/stdc++.h>
using namespace std;
void solve() {
  unsigned long long int N;
  cin >> N;
  unsigned long long int p[2];
  p[0] = 0;
  p[1] = 0;
  int curr = 0;
  while (N > 0) {
    if (N % 2) {
      p[curr % 2] += 1;
      N--;
    } else {
      if (N % 4 == 0 && N > 4) {
        p[curr % 2] += 1;
        N--;
      } else {
        p[curr % 2] += N / 2;
        N >>= 1;
      }
    }
    curr += 1;
  }
  cout << p[0] << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(0);
  ;
  int poo;
  cin >> poo;
  while (poo--) {
    solve();
  }
}
