#include <bits/stdc++.h>
using namespace std;
long long solve(long long n) {
  if (n < 5) {
    return max(1ll, n - 1);
  } else if ((n % 2) == 1 || (n % 4) == 0)
    return (n - solve(n - 1));
  return (n - solve(n / 2));
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    cout << solve(n) << endl;
  }
}
