#include <bits/stdc++.h>
using namespace std;
int ar[200005];
char ch[200005];
int n, m, ii, k;
void solve() {
  long long a;
  scanf("%lld", &a);
  long long b = a;
  long long re = 0;
  bool f = true;
  if (a % 2 == 1) f = false, a--;
  while (a > 0) {
    if ((a / 2) % 2 == 1 || a == 4) {
      re += a / 2;
      a /= 2;
      a--;
    } else {
      re++;
      a -= 2;
    }
  }
  if (f)
    printf("%lld\n", re);
  else
    printf("%lld\n", b - re);
}
int main() {
  int t = 1;
  scanf("%d", &t);
  while (t--) solve();
  return 0;
}
