#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  int t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long c = 0;
    int i = 0;
    while (n > 0) {
      long long g = 0;
      if (n % 2 == 0) {
        long long m = n / 2;
        if (m > 2 && m % 2 == 0) {
          g = 1;
        } else {
          g = m;
        }
      } else {
        g = 1;
      }
      n -= g;
      if (i++ % 2 == 0) c += g;
    }
    cout << c << '\n';
  }
  return 0;
}
