#include <bits/stdc++.h>
#define FAST_READ ios_base::sync_with_stdio(0);
#define ll long long
#define pb push_back
#define endl "\n"
#define MAXN 200010
using namespace std;
ll T,n;
ll checkprost(ll cis)
{
if(cis==2 || cis==3)return 1;
else if(cis==1 || cis%2==0 || cis%3==0)return 0;
for(ll i=5,p=2;i*i<=cis;i+=p,p=6-p)
{
if(cis%i==0)return 0;
}
return 1;
}
template<class U>
vector<U> k_factors(U n)
{
vector<U> factors;
vector<U>error;
for (U f=2;f*f<=n;f++) {
while (n%f == 0) {
factors.pb(f);
n/=f;
}
}
if(n!=1)
{
factors.pb(n);
return factors;
}
return factors;
}
set<ll>mn;
int main(){
FAST_READ;
cin>>T;
while(T--)
{
ll cnt=0;
ll maxa=-123;
cin>>n;
//n++;
ll ans=-123;
for(ll i=1;i<=n;i++)
{
cnt=0;
ll ciss=i;
vector<ll>delit=k_factors(ciss);
ll raz=delit.size();
if(raz>maxa){maxa=raz;ans=i;}
else if(raz==maxa)
{
if(i>ans)
{
ans=i;
}
}
}
cout<<ans<<endl;
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiNkZWZpbmUgRkFTVF9SRUFEIGlvc19iYXNlOjpzeW5jX3dpdGhfc3RkaW8oMCk7CiNkZWZpbmUgbGwgbG9uZyBsb25nCiNkZWZpbmUgcGIgcHVzaF9iYWNrCiNkZWZpbmUgZW5kbCAiXG4iCiNkZWZpbmUgTUFYTiAyMDAwMTAKCnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgpsbCBULG47CgpsbCBjaGVja3Byb3N0KGxsIGNpcykKewoJaWYoY2lzPT0yIHx8IGNpcz09MylyZXR1cm4gMTsKCWVsc2UgaWYoY2lzPT0xIHx8IGNpcyUyPT0wIHx8IGNpcyUzPT0wKXJldHVybiAwOwoJZm9yKGxsIGk9NSxwPTI7aSppPD1jaXM7aSs9cCxwPTYtcCkKCXsKCQlpZihjaXMlaT09MClyZXR1cm4gMDsKCX0KCXJldHVybiAxOwp9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