#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  long long x, answer, pointer, gg, counter;
  answer = 0;
  pointer = 0;
  for (int i = 0; i < t; i++) {
    cin >> x;
    counter = 0;
    answer = 0;
    while (x > 0) {
      if (x % 4 != 0 && x % 2 == 0 || x == 4) {
        gg = x / 2;
        x /= 2;
      } else {
        gg = 1;
        x -= 1;
      }
      if (counter % 2 == 0) answer = answer + gg;
      counter++;
    }
    cout << answer << '\n';
  }
}
