#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
const long long inf_ll = 1e18;
long long f(long long x) {
  if (x == 0) return 0;
  return x - (x % 2 == 1 || x % 4 == 0 && x >= 12 ? f(x - 1) : f(x / 2));
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    cout << f(n) << "\n";
  }
}
