#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1000000007;
const double PI = 3.14;
void solve();
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int t;
  cin >> t;
  while (t--) solve();
  return 0;
}
void solve() {
  long long int n, ans = 0;
  cin >> n;
  long long int temp = n;
  if (n & 1) {
    temp--;
    ans++;
  }
  long long int maxm = 0, other = 0;
  while (temp > 0) {
    long long int half = temp / 2;
    if (half & 1 || half == 2) {
      maxm += half;
      other++;
      temp = half - 1;
    } else {
      maxm++;
      if (temp > 1) {
        other++;
      }
      temp -= 2;
    }
  }
  if (n & 1) {
    ans += other;
  } else {
    ans += maxm;
  }
  cout << ans << "\n";
}
