很神奇,14会全re
#include<iostream>
using namespace std;
const int maxn=1e7+5;
int num[maxn],vis[maxn],cnt=0;
bool check(int x){
while(x){
if(x%10==7) return false;
x/=10;
}
return true;
}
void trial(){
for(int i=1;i<=maxn;i++){
if(vis[i]==0)
{
if(check(i))
{
vis[i]=++cnt;
num[cnt]=i;
}
else{
for(int j=1;i*j<maxn;j++){
vis[i*j]=-1;
}
}
}
}
}
int main(){
int t,n;
cin>>t;
trial();
while(t--){
cin>>n;
if(vis[n]==-1){
cout<<-1<<endl;
}
else
{
cout<<num[vis[n]+1]<<endl;
}
}
return 0;
}