#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    long long n, ans[2] = {0};
    cin >> n;
    int i = 0;
    while (n) {
      if (n % 2 != 0) {
        ans[i]++;
        n--;
      } else if (n % 4 != 0) {
        ans[i] += n / 2;
        n /= 2;
      } else if (n == 4) {
        ans[i] += n / 2;
        n /= 2;
      } else {
        ans[i]++;
        n--;
      }
      i = (i + 1) % 2;
    }
    cout << ans[0] << "\n";
  }
  return 0;
}
