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