#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long ans1 = 0, ans2 = 0, c1 = 0;
    long long n_new = n;
    while (n_new > 0) {
      if (c1 % 2 == 0) {
        if (n_new % 4 == 0 && n_new > 8) {
          n_new--;
          ans1++;
        } else if (n_new % 2 == 0) {
          n_new /= 2;
          ans1 += (n_new);
        } else {
          n_new--;
          ans1++;
        }
      } else {
        if (n_new % 4 == 0 && n_new > 8) {
          n_new--;
        } else if (n_new % 2 == 0) {
          n_new /= 2;
        } else {
          n_new--;
        }
      }
      c1++;
    }
    cout << ans1 << "\n";
  }
}
