#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int tc = 1;
  cin >> tc;
  while (tc--) {
    long long n, cn = 0, op = 0, x = 1;
    cin >> n;
    while (n > 0) {
      if (x) {
        x = 0;
        if (n % 2)
          cn++, n--;
        else if ((n / 2) % 2)
          cn += (n /= 2);
        else if ((n / 2) == 2)
          cn += (n /= 2);
        else
          cn++, n--;
      } else {
        x = 1;
        if (n % 2)
          op++, n--;
        else if ((n / 2) % 2)
          op += (n /= 2);
        else if ((n / 2) == 2)
          op += (n /= 2);
        else
          op++, n--;
      }
    }
    cout << cn << "\n";
  }
  return 0;
}
