#include <bits/stdc++.h>
using namespace std;
const int N = 2e1 + 2, INF = 0x3f3f3f3f, MOD = 1e9 + 7;
long long n;
bool iseven(long long n) { return n % 2 == 0; }
long long f(long long n) {
  long long ans = 0;
  bool turn = true;
  while (n) {
    if (!iseven(n) || (n != 4 && iseven(n) && iseven(n / 2))) {
      --n;
      if (turn) ++ans;
    } else {
      if (turn) ans += n / 2;
      n /= 2;
    }
    turn = !turn;
  }
  return ans;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    cin >> n;
    long long ans = 0;
    bool turn = true;
    if (iseven(n))
      cout << f(n) << endl;
    else {
      long long temp = f(n - 1);
      cout << n - temp << endl;
    }
  }
  return 0;
}
