#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const long long inf = 0x3f3f3f3f;
char intToAlphabet(long long i) { return static_cast<char>('a' + i); }
long long solve(long long n) {
  if (n < 5) {
    return max(1LL, n - 1);
  }
  if (n % 2 != 0 || n % 4 == 0) {
    return (n - solve(n - 1));
  }
  return (n - solve(n / 2));
}
void solve() {
  long long n;
  cin >> n;
  cout << solve(n) << "\n";
}
signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  srand(chrono::high_resolution_clock::now().time_since_epoch().count());
  long long t;
  cin >> t;
  while (t--) {
    solve();
  }
}
