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