#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int t, n, i, c, d;
  cin >> t;
  while (t--) {
    cin >> n;
    i = 1;
    c = 0;
    d = 0;
    if (n % 2 == 1) {
      n--;
      i++;
      c++;
    }
    while (n != 0) {
      if (i % 2 == 1) {
        if (n % 4 == 2 || n == 4) {
          c += n / 2;
          n = n / 2;
        } else {
          c += 1;
          n -= 1;
        }
      } else {
        if (n % 4 == 2 || n == 4) {
          d += n / 2;
          n /= 2;
        } else {
          d += 1;
          n -= 1;
        }
      }
      i++;
    }
    cout << c << endl;
  }
}
