#include <bits/stdc++.h>
using namespace std;
const double PI = 3.141592653589793238462643383;
const long long INF = 1e9 + 7;
const long long mod = 998244353;
int getID(char c) {
  if (c == ' ') return 0;
  return c - 'a' + 1;
}
long long pw(long long a, long long b) {
  long long res = 1ll;
  while (b) {
    if (b & 1ll) res = (res * a) % INF;
    a = (a * a) % INF;
    b >>= 1;
  }
  return res % INF;
}
void solve() {
  long long n;
  cin >> n;
  long long ans = 0, f = 1;
  while (n > 0) {
    long long val;
    if (n % 2) {
      val = 1;
      n--;
    } else if (n == 4) {
      val = 2;
      n = 2;
    } else {
      long long x = n / 2;
      if (x % 2) {
        val = x;
        n = x;
      } else {
        val = 1;
        n--;
      }
    }
    if (f) ans += val;
    f = !f;
  }
  cout << ans << "\n";
  return;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
