#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long int n;
    cin >> n;
    long long int count = 0;
    int flag = true;
    while (n > 0) {
      long long k = n / 2;
      if (n % 2 == 0) {
        if (k % 2 == 0 && k > 2) {
          if (flag == true) {
            count += 1;
            flag = false;
          } else
            flag = true;
          n -= 1;
        } else {
          if (flag == true) {
            count += k;
            flag = false;
          } else
            flag = true;
          n -= n / 2;
        }
      } else {
        if (flag == true) {
          count += 1;
          flag = false;
        } else
          flag = true;
        n -= 1;
      }
    }
    cout << count << "\n";
  }
}
