#include <bits/stdc++.h>
#pragma GCC optimize(3)
#pragma GCC optimize(2)
using namespace std;
const int maxn = 1000010;
const int mod = 1e9 + 7;
long long i, j, t;
long long ans, sum, cnt, num;
long long a[maxn], b[maxn];
long long flag = 0, n, m, q, k, l, r;
template <typename T>
void read(T &x) {
  x = 0;
  int f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + (ch ^ 48);
    ch = getchar();
  }
  x *= f;
  return;
}
template <typename T>
void write(T x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
  return;
}
long long solve(long long n) {
  if (n == 0) return 0;
  if (n & 1)
    return n - solve(n - 1);
  else {
    if (n <= 20) return n - min(solve(n - 1), solve(n / 2));
    if ((n >> 1) & 1)
      return n - solve(n / 2);
    else
      return n - solve(n - 1);
  }
}
int main() {
  read(t);
  while (t--) {
    read(n);
    cout << solve(n) << endl;
  }
  return 0;
}
