#include <bits/stdc++.h>
using namespace std;
vector<long long int> primes;
void Sieve(long long int n) {
  vector<bool> prime(n + 1, true);
  for (long long int p = 2; p * p <= n; p++) {
    if (prime[p] == true) {
      for (long long int i = p * p; i <= n; i += p) prime[i] = false;
    }
  }
  for (long long int p = 2; p <= n; p++)
    if (prime[p]) primes.push_back(p);
}
long long int dnc(long long int bas, long long int power, long long int mod) {
  if (power == 0) return 1;
  if (power % 2 == 0) {
    int res = dnc(bas, power / 2, mod);
    return 1LL * res * res % mod;
  }
  return 1LL * bas * dnc(bas, power - 1, mod) % mod;
}
long long int f[2 * 300010 + 1], inv[2 * 300010 + 1];
void precalc() {
  f[0] = inv[0] = 1;
  for (long long int temp = 1; temp <= 2 * 300010; temp++) {
    f[temp] = 1ll * temp * f[temp - 1] % 10000007;
    inv[temp] = dnc(temp, 10000007 - 2, 10000007) * inv[temp - 1] % 10000007;
  }
}
long long int comb(long long int n, long long int k) {
  if (k > n || k < 0) return 0;
  return f[n] * inv[k] % 10000007 * inv[n - k] % 10000007;
}
long long int solve(long long int n) {
  vector<long long int> a(2, 0);
  bool flag = 0;
  while (n != 0) {
    if (n % 2 == 0 && (n % 4 != 0 || n == 4)) {
      a[flag] += (n / 2);
      n /= 2;
    } else {
      a[flag]++;
      n--;
    }
    flag = !flag;
  }
  return a[0];
}
int main() {
  long long int t;
  cin >> t;
  while (t--) {
    long long int n;
    cin >> n;
    cout << solve(n);
    cout << "\n";
  }
  return 0;
}
