#include<stdio.h>
inline long long ModMultiply(long long a,long long b, long long Mod) // O(1) for (a*b)%mod
{
long long div = ((double)a
*b
/Mod
) - 1; return (a
*b
- div*Mod
)%Mod
; }
inline long long ModPow(long long a, long long b, long long Mod)
{
long long Ans=1;
while(b)
{
if(b&1) Ans = ModMultiply(Ans,a,Mod);
a = ModMultiply(a,a,Mod);
b>>=1;
}
return Ans;
}
inline int Miller(long long n, long long iteration)
{
if( (n<2) || (n!=2 && n%2==0) ) return 0; // false
long long d = n-1;
while(d%2==0) d >>= 1;
int i;
for(i=0; i<iteration; i++)
{
long long a
= rand()%(n
-1) + 1; long long temp = d;
long long x = ModPow(a,temp,n);
while(temp!=n-1 && x!=1 && x!=n-1)
{
x = ModMultiply(x,x,n);
temp <<= 1; // temp*=2
}
if (x!=n-1 && temp%2==0)
return 0;
}
return 1;
}
int main()
{
int T;
long long i,N;
while(T--)
{
if(N
== 2 || N
== 3) { printf("%lld\n",N
); continue; } for(i=N; ; i--)
{
if( Miller
(i
,2) ) { printf("%lld\n",i
); break; } }
}
return 0;
}
I2luY2x1ZGU8c3RkaW8uaD4KIAppbmxpbmUgbG9uZyBsb25nIE1vZE11bHRpcGx5KGxvbmcgbG9uZyBhLGxvbmcgbG9uZyBiLCBsb25nIGxvbmcgTW9kKSAgIC8vIE8oMSkgZm9yIChhKmIpJW1vZAp7CiAgICBsb25nIGxvbmcgZGl2ID0gKChkb3VibGUpYSpiIC9Nb2QpIC0gMTsKICAgIHJldHVybiAoYSpiIC0gZGl2Kk1vZCklTW9kOwp9CiAKaW5saW5lIGxvbmcgbG9uZyBNb2RQb3cobG9uZyBsb25nIGEsIGxvbmcgbG9uZyBiLCBsb25nIGxvbmcgTW9kKQp7CiAgIGxvbmcgbG9uZyBBbnM9MTsKICAgd2hpbGUoYikKICAgewogICAgICAgaWYoYiYxKSAgQW5zID0gTW9kTXVsdGlwbHkoQW5zLGEsTW9kKTsKICAgICAgIGEgPSBNb2RNdWx0aXBseShhLGEsTW9kKTsKICAgICAgIGI+Pj0xOwogICB9CiAgIHJldHVybiBBbnM7Cn0KCmlubGluZSBpbnQgTWlsbGVyKGxvbmcgbG9uZyBuLCBsb25nIGxvbmcgaXRlcmF0aW9uKQp7CiAgICBpZiggKG48MikgfHwgKG4hPTIgJiYgbiUyPT0wKSApICByZXR1cm4gMDsgIC8vIGZhbHNlCiAgICBsb25nIGxvbmcgZCA9IG4tMTsKICAgIHdoaWxlKGQlMj09MCkgICAgZCA+Pj0gMTsKICAgIGludCBpOwogICAgZm9yKGk9MDsgaTxpdGVyYXRpb247IGkrKykKICAgIHsKICAgICAgICBsb25nIGxvbmcgYSA9IHJhbmQoKSUobi0xKSArIDE7CiAgICAgICAgbG9uZyBsb25nIHRlbXAgPSBkOwogICAgICAgIGxvbmcgbG9uZyB4ID0gTW9kUG93KGEsdGVtcCxuKTsKICAgICAgICB3aGlsZSh0ZW1wIT1uLTEgJiYgeCE9MSAmJiB4IT1uLTEpCiAgICAgICAgewogICAgICAgICAgICB4ID0gTW9kTXVsdGlwbHkoeCx4LG4pOwogICAgICAgICAgICB0ZW1wIDw8PSAxOyAgLy8gdGVtcCo9MgogICAgICAgIH0KICAgICAgICBpZiAoeCE9bi0xICYmIHRlbXAlMj09MCkKICAgICAgICByZXR1cm4gMDsKICAgIH0KICByZXR1cm4gMTsKfQoKaW50IG1haW4oKQp7CiAgICBpbnQgVDsKICAgIGxvbmcgbG9uZyBpLE47CiAgICBzY2FuZigiJWQiLCZUKTsKICAgIHdoaWxlKFQtLSkKICAgIHsKICAgICAgICBzY2FuZigiJWxsZCIsJk4pOwogICAgICAgIGlmKE4gPT0gMiB8fCBOID09IDMpICB7ICBwcmludGYoIiVsbGRcbiIsTik7ICBjb250aW51ZTsgfQogICAgICAgIGZvcihpPU47ICA7IGktLSkKICAgICAgICB7CiAgICAgICAgICAgIGlmKCBNaWxsZXIoaSwyKSApICB7ICBwcmludGYoIiVsbGRcbiIsaSk7ICBicmVhazsgIH0KICAgICAgICB9CiAgICB9CiAgcmV0dXJuIDA7Cn0=