#include <bits/stdc++.h>
using namespace std;
long long power(long long r) {
  long long ans = 1;
  while (r--) {
    ans = ans * 2;
  }
  return ans;
}
void solve() {
  long long n, s = 0;
  cin >> n;
  while (n > 0) {
    if (n == 4) {
      s += 3;
      break;
    } else if (n % 2 == 0) {
      if ((n / 2) % 2 != 0) {
        s += n / 2;
        n /= 2;
      } else {
        s += 1;
        n--;
      }
      n--;
    } else {
      s += 1;
      n--;
      if (n == 4) {
        s += 1;
        n = 0;
      } else if ((n / 2) % 2 != 0) {
        n /= 2;
      } else {
        n--;
      }
    }
  }
  cout << s << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
}
