#include <iostream>
using namespace std;

int main() {
    for (int i = 1; i <= 500; i++) {
        if (i % 3 == 2 && i % 5 == 3 && i % 7 == 2) {
            cout << i << endl;
        }
    }
    return 0;
}    
/**************************************************************
	Problem: 1021
	User: fuyijun
	Language: C++
	Result: Accepted
	Time:3 ms
	Memory:2072 kb
****************************************************************/