#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    long long sum = 0, n, a;
    cin >> n;
    a = n;
    if (n % 2 == 0) {
      while (n > 0) {
        if (n == 4) {
          sum += 3;
          break;
        }
        if (n % 4 == 0 || n % 2 != 0) {
          sum += 1;
          n -= 1;
        } else {
          sum += n / 2;
          n /= 2;
        }
        n -= 1;
      }
    } else {
      n -= 1;
      while (n > 0) {
        if (n == 4) {
          sum += 3;
          break;
        }
        if (n % 4 == 0 || n % 2 != 0) {
          sum += 1;
          n -= 1;
        } else {
          sum += n / 2;
          n /= 2;
        }
        n -= 1;
      }
      sum = a - sum;
    }
    cout << sum << "\n";
  }
  return 0;
}
