#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long int x, i, j = 1, l, s = 0;
    cin >> x;
    while (x > 0) {
      if (x % 2 == 0) {
        if ((x / 2) % 2 != 0) {
          s = s + (x / 2);
          x = x / 2;
          x--;
        } else {
          if (x / 2 == 2) {
            s = s + 3;
            x = 0;
          } else {
            s++;
            x = x - 2;
          }
        }
      } else {
        s++;
        x--;
        if (x / 2 == 2)
          x = x - 2;
        else if ((x / 2) % 2 != 0)
          x = x / 2;
        else
          x--;
      }
    }
    cout << s << "\n";
  }
  return 0;
}
