Const A:array [1..3] of integer=(3,4,7);
var n, m, i,j :integer; s,t:string;
begin
for i :=1 to 9 do begin
s:='125';str(i,t);s:= t + s + t;
for j:= 1 to 3 do begin
n:= strTOInt(s);if n mod a[j] = 0 then m:= m +1;
//writeln(n);end;
if m = 3 then writeln(n);
s:='';m:=0;end;end.