#include<bits/stdc++.h>
using namespace std;
bool ss(int n){
    bool r=true;
    if(n<=1) r=false;
    else if(n==2) r=true;
    else{
        for(int i=2;i<=sqrt(n);i++){
            if(n%i==0){
                r=false;
                break;
            }
        }
    }
    return r;
}
bool hw(int n){
    bool r=false;
    int s=0,x=n;
    while(n!=0){
        s=s*10+n%10;
        n=n/10;
    }
    if(s==x) r=true;
    else r=false;
    return r;
}
int main(){
    for(int i=10;i<=1000;i++){
            if(hw(i)&&ss(i)){
                cout<<i<<endl;
            }
    }
     
     
 
    return 0;
}
/**************************************************************
	Problem: 1142
	User: wuyichen
	Language: C++
	Result: Accepted
	Time:5 ms
	Memory:2072 kb
****************************************************************/