#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, t, ans, a, b;
  scanf("%lld", &t);
  while (t--) {
    scanf("%lld", &n);
    a = n;
    ans = 0;
    if (a % 2 == 0) {
      while (a) {
        b = a / 2;
        if (b % 2) {
          ans += b;
          a = b - 1;
        } else {
          if (a != 4) {
            ans++;
            a -= 2;
          } else {
            ans += 3;
            a = 0;
          }
        }
      }
      printf("%lld\n", ans);
    } else {
      a--;
      while (a) {
        b = a / 2;
        if (b % 2) {
          ans += b;
          a = b - 1;
        } else {
          if (a != 4) {
            ans++;
            a -= 2;
          } else {
            ans += 3;
            a = 0;
          }
        }
      }
      printf("%lld\n", n - ans);
    }
  }
}
