#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  long long t, n, sum;
  cin >> t;
  while (t--) {
    cin >> n;
    sum = 0;
    for (;;) {
      if (n % 2 == 0) {
        if (n % 4 != 0 || n == 4) {
          sum += n / 2;
          n /= 2;
        } else {
          sum++;
          n--;
        }
      } else {
        sum++;
        n--;
      }
      if (n == 0) break;
      if (n % 2 == 0) {
        if (n % 4 != 0 || n == 4)
          n /= 2;
        else
          n--;
      } else
        n--;
      if (n == 0) break;
    }
    cout << sum << endl;
  }
  return 0;
}
