#include <bits/stdc++.h>
using namespace std;
void my_dbg() { cout << endl; }
template <typename Arg, typename... Args>
void my_dbg(Arg A, Args... B) {
  cout << ' ' << A;
  my_dbg(B...);
}
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
const int inf = INT_MAX;
const int ninf = INT_MIN;
const int mod = 1e9 + 7;
const int maxN = 1e6 + 2;
void solve() {
  ll n;
  scanf("%lld", &n);
  ll sum = 0;
  int turn = 1;
  while (n > 0) {
    if (n & 1) {
      sum += turn;
      n--;
    } else {
      if ((n / 2) & 1 or (n / 2) == 2) {
        sum += turn * (n / 2);
        n /= 2;
      } else {
        sum += turn;
        n--;
      }
    }
    turn ^= 1;
  }
  printf("%lld\n", sum);
}
int main() {
  int t = 1;
  scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}
