#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 7;
int T;
long long n, ans1, ans2, tmp, cnt;
int main() {
  scanf("%d", &T);
  while (T--) {
    scanf("%lld", &n);
    ans1 = ans2 = 0;
    cnt = 0;
    while (n) {
      if ((n % 4 == 0 && n > 4) || n % 2 == 1) {
        if (cnt % 2 == 0) {
          ans1++;
          n--;
        } else {
          ans2++;
          n--;
        }
      } else {
        if (cnt % 2 == 0) {
          ans1 += n / 2;
          n /= 2;
        } else {
          ans2 += n / 2;
          n /= 2;
        }
      }
      cnt++;
    }
    printf("%lld\n", ans1);
  }
  return 0;
}
