var
a,b,c,d,e:integer;
begin
for a:=0 to 9 do
for b:=0 to 9 do
for c:=0 to 9 do
for d:=0 to 9 do
for e:=0 to 9 do
if ((a*10000+b*1000+c*100+d*10+e) mod 3=0)and((a*10000+b*1000+c*100+d*10+e) mod 7=0)and((a*10000+b*1000+c*100+d*10+e) mod 5=0)and((a*10000+b*1000+c*100+d*10+e) mod 13=0)
then writeln(a,b,c,e,d);
end.