#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int a[5] = {1, 3, 5, 7, 9};
int p[5] = {2, 3, 5, 7};
int n;
bool is_prime(int x) {
if (x == 1) return false;
if (x == 2) return 1;
for (register int i = 2; i * i <= x; i ++)
if (x % i == 0) return false;
return true;
}
void dfs(int k, int w) {
if (w == n) {
printf("%d\n", k);
return ;
}
else for (register int i = 0; i < 5; i ++) {
if (is_prime(k * 10 + a[i]))
dfs(k * 10 + a[i], w + 1);
}
}
int main() {
freopen("sprime.in", "r", stdin);
freopen("sprime.out", "w", stdout);
scanf("%d", &n);
for (register int i = 0; i < 4; i ++)
dfs(p[i], 1);
return 0;
}