#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<bitset>
#include<numeric>
#include<algorithm>
#include<stack>
//sum of sqaures of natural no--- n(n + 1)(2n + 1)/6
using namespace std;
typedef long long ll;
typedef long long int lli;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pi;
typedef vector<pi > vii;
typedef vector<ll> vl;
typedef vector<vi> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl > vll;
const ll mo=(1000000000 + 7);
#define f(i,a,b) for(int i=a;i<b;i++)
#define fm(i,a,b) for(int i=a;i>b;i--)
#define fbe(s) (s.begin(),s.end())
#define fs(p) p.size()
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define it iterator
int compare(const void* a, const void* b)
{
const int* x = (int*) a;
const int* y = (int*) b;
if (*x > *y)
return 1;
else if (*x < *y)
return -1;
return 0;
}
void solve()
{
ll n;
cin>>n;
ll i=0;
while(n>0)
{
if(n==4)
{
i+=3;
break;
}
else
{
if(n==4)
{
i++;
break;
}
if(n%2)
{
n=n-1;
i++;
}
else
{
if(n%4==0)
{
n=n-1;
i++;
}
else
{
i+=n/2;
n=n/2;
}
}
if(n==4)
{
i++;
break;
}
if(n%2)
{
n=n-1;
}
else
{
if(n%4==0)
{
n=n-1;
}
else
{
n=n/2;
}
}
}
}
cout<<i<<endl;
}
int main()
{
ios::sync_with_stdio(0); cin.tie(0);
int t;
cin>>t;
while(t-->0)
{
solve();
}
}
1277C - As Simple as One and Two | 1301A - Three Strings |
460A - Vasya and Socks | 1624C - Division by Two and Permutation |
1288A - Deadline | 1617A - Forbidden Subsequence |
914A - Perfect Squares | 873D - Merge Sort |
1251A - Broken Keyboard | 463B - Caisa and Pylons |
584A - Olesya and Rodion | 799A - Carrot Cakes |
1569B - Chess Tournament | 1047B - Cover Points |
1381B - Unmerge | 1256A - Payment Without Change |
908B - New Year and Buggy Bot | 979A - Pizza Pizza Pizza |
731A - Night at the Museum | 742A - Arpa’s hard exam and Mehrdad’s naive cheat |
1492A - Three swimmers | 1360E - Polygon |
1517D - Explorer Space | 1230B - Ania and Minimizing |
1201A - Important Exam | 676A - Nicholas and Permutation |
431A - Black Square | 474B - Worms |
987B - High School Become Human | 1223A - CME |