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