#include<bits/stdc++.h>
using namespace std;
char c[110][110];
int n;
bool zh(int x){
if(x==1) return false;
for(int i=2;i<x;i++){
if(x%i==0){
return false;
}
}
return true;
}
void dfs(int step,int yu){
if(step>n){
cout<<yu<<endl;
return;
}
for(int i=1;i<=9;i++){
if(zh(yu*10+i)) dfs(step+1,yu*10+i);
}
}
int main(){
cin>>n;
dfs(1,0);
return 0;
}
/**************************************************************
Problem: 1943
User: liyunshuo
Language: C++
Result: Accepted
Time:873 ms
Memory:2084 kb
****************************************************************/