#include <bits/stdc++.h>
using namespace std;
long long int t, N, i, j, b, d, n, k, req, ch, x, rem, maxi, sum, z, tot, kount,
    len, cnt, brw, brw1;
vector<long long int> v;
unordered_map<long long int, long long int> umap;
bool c;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> t;
  while (t--) {
    ch = 0;
    cin >> n;
    c = 1;
    while (n != 0) {
      if (n % 2 == 0) {
        if (n == 4) {
          if (c == 1) {
            ch += 3;
          } else
            ch += 1;
          n = 0;
        } else {
          if (c == 1) {
            if ((n / 2) % 2 == 0) {
              ch += 1;
              n = n - 1;
              c = c ^ 1;
            } else {
              ch += n / 2;
              n = n / 2;
              c = c ^ 1;
            }
          } else {
            if ((n / 2) % 2 == 0) {
              n = n - 1;
              c = c ^ 1;
            } else {
              n = n / 2;
              c = c ^ 1;
            }
          }
        }
      } else {
        if (c == 1) {
          ch += 1;
          n = n - 1;
          c = c ^ 1;
        } else {
          n = n - 1;
          c = c ^ 1;
        }
      }
    }
    cout << ch << endl;
  }
}
