#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long t, n, i, j, k, ans, c, x;
  cin >> t;
  while (t--) {
    cin >> n;
    ans = 0;
    c = 0;
    while (n > 0) {
      if ((n % 4 == 0) && (n > 8))
        x = 1;
      else if (n % 2 == 0)
        x = n / 2;
      else
        x = 1;
      if (c == 0) ans += x;
      c = 1 - c;
      n -= x;
    }
    cout << ans << "\n";
  }
  return 0;
}
