#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long c = 0, d = 0;
    int tt = 0;
    while (n > 0) {
      long long val;
      if (n % 2 == 1)
        val = 1;
      else if ((n / 2) % 2 == 0) {
        if (n > 11)
          val = 1;
        else
          val = n / 2;
      } else
        val = n / 2;
      if (tt == 0) c += val;
      tt = tt ^ 1;
      n = n - val;
    }
    cout << c << endl;
  }
  return 0;
}
