#include <bits/stdc++.h>
using namespace std;
const bool TEST = false;
const long double PI = 3.1415926535897932384626433832795;
const int inf = 2147483647;
const long long infll = 9223372036854775807;
const int mod = 1000000007;
long long max(int a, long long b) { return max((long long)a, b); }
long long min(int a, long long b) { return min((long long)a, b); }
long long min(long long a, int b) { return min(a, (long long)b); }
long long max(long long a, int b) { return max(a, (long long)b); }
long long dx[] = {0, 0, 1, -1};
long long dy[] = {1, -1, 0, 0};
long long dxk[] = {0, 0, 1, -1, 1, 1, -1, -1};
long long dyk[] = {1, -1, 0, 0, 1, -1, 1, -1};
bool isint(double d) { return (d == floor(d)); }
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) { return a * b / gcd(a, b); }
long long ipow(long long a, long long b) {
  if (a == 1 || b == 0) return 1;
  long long r = 1;
  for (long long i = 1; i <= b; i++) r *= a;
  return r;
}
long long power(long long a, long long b) {
  if (a == 1 || b == 0) return 1;
  long long c = power(a, b / 2);
  long long res = (c * c) % mod;
  ;
  if (b % 2) res = (res * (a % mod)) % mod;
  return res;
}
bool isPrime(int n) {
  if (n == 1) return false;
  for (int i = 2; i <= sqrt(n); i++)
    if (n % i == 0) return false;
  return true;
}
string toBase(int n, int b) {
  string oval = "";
  while (n >= 1) {
    if (n % b < 10)
      oval += to_string(n % b);
    else
      oval += 'A' + (n % b - 10);
    n /= b;
  }
  reverse(oval.begin(), oval.end());
  return oval;
}
int logtwo(long long n) {
  int res = 0;
  while (n % 2 == 0) n /= 2, res++;
  return res;
}
long long cal(long long n) {
  if (n == 0) return 0;
  if (n == 1) return 1;
  if (n % 4 == 0 && n > 4) return cal(n - 2) + 1;
  if (n % 2 == 0) return n / 2 + n / 2 - cal(n / 2);
  return 1 + n - 1 - cal(n - 1);
}
void Solve() {
  long long n;
  cin >> n;
  cout << cal(n) << '\n';
}
int main() {
  if (!TEST) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
  }
  int t;
  cin >> t;
  while (t--) Solve();
  if (TEST) {
    cout << '\n';
    system("pause");
  }
  return 0;
}
