#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void debug(vector<T> v) {
  cout << "\ndebug(vector)\n";
  long long i;
  for (i = 0; i < v.size(); i++) cout << v[i] << " ";
  cout << "\n\n";
}
inline bool prime(int n) {
  int i;
  for (i = 2; i * i <= n; i++)
    if (n % i == 0) return false;
  return true;
}
bool palindrome(string s) {
  for (int i = 0; i < s.length() / 2; i++) {
    if (s[i] != s[s.length() - 1 - i]) return 0;
  }
  return 1;
}
void solve() {
  long long n;
  cin >> n;
  long long score = 0;
  long long count = 1;
  while (n) {
    if (n == 4 && count % 2) {
      score = score + 3;
      break;
    } else if (n == 4 && count % 2 == 0) {
      score = score + 1;
      break;
    }
    if (n % 2 == 0 && (n / 2) % 2 != 0) {
      if (count % 2 == 1) score = score + n / 2;
      n = n / 2;
    } else if (n % 2 == 0 && (n / 2) % 2 == 0) {
      if (count % 2 == 1) score++;
      n = n - 1;
    } else if (n % 2 == 1) {
      if (count % 2 == 1) score = score + 1;
      n = n - 1;
    }
    count++;
  }
  cout << score << endl;
}
int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
