#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, x, cnt = 0, tot1 = 0;
  cin >> x;
  for (int i = 0; i < x; i++) {
    cin >> n;
    tot1 = 0;
    cnt = 0;
    while (n > 0) {
      long long selisih = 0;
      if (n % 4 == 0 && n > 8) {
        selisih = 1;
        n--;
        if (cnt % 2 == 0) tot1 += selisih;
      } else if (n % 2 == 1) {
        selisih = 1;
        n--;
        if (cnt % 2 == 0) tot1 += selisih;
      } else if (n % 4 == 2 || n <= 8) {
        n = n / 2;
        selisih = n;
        if (cnt % 2 == 0) tot1 += selisih;
      }
      cnt++;
    }
    cout << tot1 << endl;
  }
}
