#include <bits/stdc++.h>
using namespace std;
const int N = 1e6;
bool prime_poo(long long prime){
if (prime <= 1)return false;
for (long long p = 2; p < prime; p++){
if (prime % p == 0){
return false;
}
}
return true;
}
signed main(){
ios::sync_with_stdio(false);
freopen("SODER.INP","r",stdin);
freopen("SODER.OUT","w",stdout);
long long n, a[N];
string s;
cin >> n;
for (long long i = 0; i < n; i++){
cin >> a[i];
long long b = a[i];
while(b > 0){
if (prime_poo(b) == false){
break;
}
else if (b/10 == 0){
cout << a[i];
if (i+1 != n){
cout << endl;
}
break;
}
else {
b/=10;
}
}
}
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CmNvbnN0IGludCBOID0gMWU2OwoKYm9vbCBwcmltZV9wb28obG9uZyBsb25nIHByaW1lKXsKICAgIGlmIChwcmltZSA8PSAxKXJldHVybiBmYWxzZTsKICAgIGZvciAobG9uZyBsb25nIHAgPSAyOyBwIDwgcHJpbWU7IHArKyl7CiAgICAgICAgaWYgKHByaW1lICUgcCA9PSAwKXsKICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgICAgIH0KICAgIH0KICAgIHJldHVybiB0cnVlOwp9CgpzaWduZWQgbWFpbigpewogICAgaW9zOjpzeW5jX3dpdGhfc3RkaW8oZmFsc2UpOwoJZnJlb3BlbigiU09ERVIuSU5QIiwiciIsc3RkaW4pOwoJZnJlb3BlbigiU09ERVIuT1VUIiwidyIsc3Rkb3V0KTsKCiAgICBsb25nIGxvbmcgbiwgYVtOXTsKICAgIHN0cmluZyBzOwogICAgY2luID4+IG47CiAgICBmb3IgKGxvbmcgbG9uZyBpID0gMDsgaSA8IG47IGkrKyl7CiAgICAgICAgY2luID4+IGFbaV07CiAgICAgICAgbG9uZyBsb25nIGIgPSBhW2ldOwogICAgICAgIHdoaWxlKGIgPiAwKXsKICAgICAgICAgICAgaWYgKHByaW1lX3BvbyhiKSA9PSBmYWxzZSl7CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgfQogICAgICAgICAgICBlbHNlIGlmIChiLzEwID09IDApewogICAgICAgICAgICAgICAgY291dCA8PCBhW2ldOwogICAgICAgICAgICAgICAgaWYgKGkrMSAhPSBuKXsKICAgICAgICAgICAgICAgICAgICBjb3V0IDw8IGVuZGw7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgfQogICAgICAgICAgICBlbHNlIHsKICAgICAgICAgICAgICAgICAgICBiLz0xMDsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgIH0KfQo=