#include <bits/stdc++.h>
using namespace std;
int main() {
  FILE *inF, *outF;
  inF = fopen("in", "r");
  outF = fopen("out", "w");
  inF = stdin;
  outF = stdout;
  int t;
  fscanf(inF, "%d", &t);
  while (t--) {
    long long n;
    fscanf(inF, "%lld", &n);
    long long res = 0;
    bool turn = true;
    while (n > 0) {
      if (n % 4 == 0 && n > 8) {
        if (turn) res += 1;
        n -= 1;
      } else if (n % 2 == 0) {
        if (turn) res += n / 2;
        n /= 2;
      } else {
        if (turn) res += 1;
        n -= 1;
      }
      turn = !turn;
    }
    fprintf(outF, "%lld\n", res);
  }
  return 0;
}
