#include<bits/stdc++.h>
using namespace std;
char c[100][100];
int n;
bool zs(int x){
	if(x==1) return false;
	for(int i=2;i<=x;i++){
		if(x%i==0){
			return false;
		}
	}
	return false;
}
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: zhangzekai
	Language: C++
	Result: Compile Error
****************************************************************/