#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  long long N, i;
  while (t--) {
    long long coin[2] = {0};
    i = 0;
    cin >> N;
    while (N) {
      if (!(N & 1) && (N / 2) & 1 || N == 4) {
        N = N >> 1;
        coin[++i & 1] += N;
      } else {
        N--;
        coin[++i & 1]++;
      }
    }
    cout << coin[1] << endl;
  }
}
