#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;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwpib29sIGNoZWNrIChpbnQgbil7CglpbnQgcCA9IDA7CgoJd2hpbGUgKG4gPiAwKXsKCQlwICs9IG4gJSAxMDsKCQluIC89IDEwOwoJfQoJcmV0dXJuIHAgPCAxMCA7Cn0KaW50IG1haW4oKSB7CgkKCWZvciAoaW50IGkgPSAwOyBpIDw9IDEwMDA7IGkrPTMpewoJCWlmKGkgJSA1ICE9IDAgJiYgY2hlY2soaSkpewoJCQlzdGQ6OmNvdXQgPDwgaSA8PCBlbmRsOwoJCX0KCX0KCXJldHVybiAwOwp9