#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int MAXN = 2e5 + 5;
const int inf = 0x3f3f3f3f;
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    int f = 0;
    long long ans1 = 0, ans2 = 0;
    while (n) {
      if (f == 0) {
        if (n & 1) {
          ans1++;
          n--;
        } else if ((n / 2) & 1 || n / 2 == 2) {
          ans1 += n / 2;
          n /= 2;
        } else {
          ans1++;
          n--;
        }
      } else {
        if (n & 1) {
          ans2++;
          n--;
        } else if ((n / 2) & 1 || n / 2 == 2) {
          ans2 += n / 2;
          n /= 2;
        } else {
          ans2++;
          n--;
        }
      }
      f ^= 1;
    }
    cout << ans1 << endl;
  }
}
