#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  long long T, n;
  cin >> T;
  for (; T--; cout << "\n") {
    long long x, ans = 0;
    cin >> x;
    bool turn = 1;
    while (x > 0) {
      if (x % 2 == 0) {
        if ((x / 2) % 2 != 0 or x / 2 == 2) {
          if (turn) ans += x / 2;
          x /= 2;
        } else {
          if (turn) ans++;
          x--;
        }
      } else {
        if (turn) ans++;
        x--;
      }
      turn = !turn;
    }
    cout << ans;
  }
}
