#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n;
  cin >> n;
  long long ct = 0, sum = 0, tr = n;
  while (n > 0) {
    if (n % 4 == 0 && n != 4) {
      n -= 1;
    } else if (n % 2 == 0) {
      n -= (n / 2);
    } else {
      n -= 1;
    }
    ct++;
    if (ct % 2 != 0) {
      sum += tr - n;
      tr = n;
    } else {
      tr = n;
    }
  }
  cout << sum << "\n";
}
int main() {
  int t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
