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