#include <bits/stdc++.h>
using namespace std;
bool comparator_2(pair<long long, long long>& a,
                  pair<long long, long long>& b) {
  return (a.second <= b.second);
}
bool comparator_1(pair<long long, long long>& a,
                  pair<long long, long long>& b) {
  return (a.first <= b.first);
}
void compressArray(vector<long long>& array) {
  map<long long, int> rank_;
  for (auto& i : array) {
    rank_[i] = 1;
  }
  int r = 1;
  for (auto& i : rank_) {
    i.second = r++;
  }
  for (long long i = 0; i < array.size(); i += 1) {
    array[i] = rank_[array[i]];
  }
}
long long solve(long long n) {
  long long ans = 0;
  while (n) {
    if (n & 1)
      n--;
    else {
      if (n == 4) {
        ans += 2;
        n -= 2;
      } else if ((n / 2) & 1) {
        ans += (n / 2);
        n -= n / 2;
      } else {
        n--;
        ans++;
      }
    }
  }
  return ans;
}
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  int t = 1;
  cin >> t;
  while (t--) {
    long long n, ans = 0;
    cin >> n;
    if (n & 1) {
      ans = 1 + n - 1 - solve((n - 1));
    } else
      ans += solve(n);
    cout << ans << '\n';
  }
  return 0;
}
