Function sum_del(x: longint): longint;
var
s, i: longint;
begin
s := 0;
for i := 1 to x div 2 do
if x mod i = 0 then
s := s + i;
sum_del := s;
end;
var
i, s1, s2: longint;
begin
for i := 1 to 100000 do
begin
s1 := sum_del(i);
s2 := sum_del(s1);
if (s2 = i) and (s1 < i) then
writeln(s1, ' ', i);
end;
end.