#include <bits/stdc++.h>
using namespace std;
long long n;
long long storage;
long long tests;
int main() {
  cin >> tests;
  while (tests--) {
    cin >> n;
    storage = 0;
    while (n > 0) {
      if (n % 4 == 0 && n != 4) {
        storage++;
        n -= 2;
      } else if (n % 2 == 0) {
        storage += n / 2;
        n = n / 2 - 1;
      } else {
        storage += 1;
        n--;
        if (n % 4 == 0 && n != 4) {
          n--;
        } else if (n % 2 == 0) {
          n /= 2;
        } else {
          n--;
        }
      }
    }
    cout << storage << endl;
  }
  return 0;
}
