#include <bits/stdc++.h>
using namespace std;
int read() {
  int s = 0, ch;
  do ch = getchar();
  while (!isdigit(ch));
  while (isdigit(ch)) s = s * 10 + ch - '0', ch = getchar();
  return s;
}
int nread() {
  int s = 0, ch, neg = 0;
  do ch = getchar(), neg |= (ch == '-');
  while (!isdigit(ch));
  while (isdigit(ch)) s = s * 10 + ch - '0', ch = getchar();
  return neg ? -s : s;
}
long long n;
long long move() {
  if (n > 4 && n % 4 == 0) {
    --n;
    return 1;
  }
  if (n & 1) {
    --n;
    return 1;
  } else {
    n /= 2;
    return n;
  }
}
int main(void) {
  int T;
  scanf("%d", &T);
  while (T--) {
    scanf("%lld", &n);
    long long sum = 0;
    int op = 0;
    while (n) {
      if (op)
        move();
      else
        sum += move();
      op ^= 1;
    }
    printf("%lld\n", sum);
  }
  return 0;
}
