#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t;
  cin >> t;
  while (t--) {
    long long int n;
    cin >> n;
    long long int chanek = 0, other = 0;
    long long int i = 0;
    while (n > 0) {
      if (i % 2 == 0) {
        if (n % 2 == 0) {
          if ((n / 2) % 2 == 0 && (n / 2) > 4) {
            chanek++;
            n--;
          } else {
            chanek += n / 2;
            n = n / 2;
          }
        } else {
          chanek++;
          n--;
        }
      } else {
        if (n % 2 == 0) {
          if ((n / 2) % 2 == 0 && (n / 2) > 4) {
            n--;
            other++;
          } else {
            other += n / 2;
            n = n / 2;
          }
        } else {
          other++;
          n--;
        }
      }
      i++;
    }
    cout << chanek;
    cout << "\n";
  }
  return 0;
}
