#include <iostream>

typedef unsigned I;template<I o,I O,void(*i)(I)>struct l{void
operator()(){i(o);l<o+1,O,i>()();}};template<I i,void(*O)(I)>
struct l<i,i,O>{void operator()(){}};template<I O> I o(){ret\
urn o<O-1>()*10;}template<> I o<1>() {return 1;}template<I i>
struct O{I operator()(I _){I l =_/o<i>()%10;if(!l)throw 1U;r\
eturn!(_%l);}};void _(I o){try{I l=O<2>()(o)+O<1>()(o)+O<3>()
(o);if(l)std::cout<<o<<'\n';}catch(I){}}int main(){l<111,1000
,_>()();}
