#include <iostream>
#include <cmath>
#include <queue>
#include <vector>
using namespace std;
int n;
queue<int> res;
bool nto(int x) {
if (x < 2)
return false;
for (int i = 2; i <= sqrt(x); i++)
if (x % i == 0)
return false;
return true;
}
int len(int x) {
int d = 1;
while (x / 10 != 0) {
x /= 10;
d++;
}
return d;
}
void solve(int n) {
if (n == 1) {
res.push(2);
res.push(3);
res.push(5);
res.push(7);
return;
}
solve(n - 1);
bool stop = false;
while (!stop) {
int x = res.front();
if (len(x) == n)
stop = true;
else {
for (int i = 1; i < 10; i++)
if (nto(x*10 + i)) {
res.push(x*10 + i);
}
res.pop();
}
}
}
int main() {
cin>> n;
solve(n);
int d = 0;
while (!res.empty()) {
cout<< ++d<< " "<< res.front()<< endl;
res.pop();
}
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8Y21hdGg+CiNpbmNsdWRlIDxxdWV1ZT4KI2luY2x1ZGUgPHZlY3Rvcj4KCnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgbjsKcXVldWU8aW50PiByZXM7Cgpib29sIG50byhpbnQgeCkgewogICAgaWYgKHggPCAyKQogICAgICAgIHJldHVybiBmYWxzZTsKICAgIGZvciAoaW50IGkgPSAyOyBpIDw9IHNxcnQoeCk7IGkrKykKICAgICAgICBpZiAoeCAlIGkgPT0gMCkKICAgICAgICAgICAgcmV0dXJuIGZhbHNlOwogICAgcmV0dXJuIHRydWU7Cn0KCmludCBsZW4oaW50IHgpIHsKICAgIGludCBkID0gMTsKICAgIHdoaWxlICh4IC8gMTAgIT0gMCkgewogICAgICAgIHggLz0gMTA7CiAgICAgICAgZCsrOwogICAgfQogICAgcmV0dXJuIGQ7Cn0Kdm9pZCBzb2x2ZShpbnQgbikgewogICAgaWYgKG4gPT0gMSkgewogICAgICAgIHJlcy5wdXNoKDIpOwogICAgICAgIHJlcy5wdXNoKDMpOwogICAgICAgIHJlcy5wdXNoKDUpOwogICAgICAgIHJlcy5wdXNoKDcpOwogICAgICAgIHJldHVybjsKICAgIH0KICAgIHNvbHZlKG4gLSAxKTsKICAgIAogICAgYm9vbCBzdG9wID0gZmFsc2U7CiAgICB3aGlsZSAoIXN0b3ApIHsKICAgICAgICBpbnQgeCA9IHJlcy5mcm9udCgpOwogICAgICAgIGlmIChsZW4oeCkgPT0gbikgCiAgICAgICAgICAgIHN0b3AgPSB0cnVlOwogICAgICAgIGVsc2UgewogICAgICAgICAgICBmb3IgKGludCBpID0gMTsgaSA8IDEwOyBpKyspCiAgICAgICAgICAgICAgICBpZiAobnRvKHgqMTAgKyBpKSkgewogICAgICAgICAgICAgICAgICAgIHJlcy5wdXNoKHgqMTAgKyBpKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgcmVzLnBvcCgpOwogICAgICAgIH0gICAKICAgIH0KfQoKCmludCBtYWluKCkgewogICAgY2luPj4gbjsKICAgIHNvbHZlKG4pOwogICAgaW50IGQgPSAwOwogICAgd2hpbGUgKCFyZXMuZW1wdHkoKSkgewogICAgICAgIGNvdXQ8PCArK2Q8PCAiICI8PCByZXMuZnJvbnQoKTw8IGVuZGw7CiAgICAgICAgcmVzLnBvcCgpOwogICAgfQp9