#include <iostream>
#include <bitset>
#include <vector>
#include <cmath>
using namespace std;

const int MAX = 200000000;
const int SQRTM = (int)sqrt(MAX) + 1;
bitset<MAX / 2> a;
int main()
{
    a.set();
	a[0] = false;
	for (int i = 1; i < SQRTM / 2; i++) if (a[i])
		for (int j = 2 * i * (i + 1); j < MAX / 2; j += i + i + 1)
			a[j] = false;

    for (int i = 50000001; i < MAX / 2; i += 2)
        if (a[i] && a[i + 9] && a[i + 18] && a[i + 69] && a[i + 99] &&
            a[i + 120] && a[i + 129])
            cout << 2 * i + 1 << endl;
}
