#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int inf = 1e9;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long ans = 0;
    while (n) {
      if (n % 2 == 0 && (n % 4 || n == 4)) {
        n /= 2;
        ans += n;
      } else {
        n--;
        ans++;
      }
      if (n == 0) break;
      if (n % 2 == 0 && (n % 4 || n == 4)) {
        n /= 2;
      } else {
        n--;
      }
    }
    cout << ans << endl;
  }
}
