#include typedef long long ll; inline ll calc(ll x){ if(x % 2 == 0){ return x / 2 % 3 == 2 ? x - 1 : x / 2; }else{ return x / 2 % 3 == 0 ? x - x / 3 : x / 6; } return 0; } int main(){ std::ios::sync_with_stdio(false),std::cin.tie(0); int t; ll n; std::cin >> t; while(t--) std::cin >> n,std::cout << calc(n) << '\n'; }