#include <iostream>
using namespace std;
bool check (int n){
	int p = 0;

	while (n > 0){
		p += n % 10;
		n /= 10;
	}
	return p < 10 ;
}
int main() {
	
	for (int i = 0; i <= 1000; i+=3){
		if(i % 5 != 0 && check(i)){
			std::cout << i << endl;
		}
	}
	return 0;
}