#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long int n;
    bool flag = true;
    long long int ans = 0;
    cin >> n;
    while (n > 0) {
      if (flag) {
        if (((n % 4ll == 0) && (n != 4)) || (n & 1)) {
          ans += 1ll;
          n -= 1ll;
        } else {
          ans += n / 2ll;
          n = n / 2ll;
        }
        flag = false;
      } else {
        if (((n % 4ll == 0) && (n != 4)) || (n & 1)) {
          n -= 1ll;
        } else {
          n = n / 2ll;
        }
        flag = true;
      }
    }
    cout << ans << endl;
  }
}
