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