Var
a, b, c, d: integer;
begin
for a := 1 to 9 do
for b := 0 to 9 do
if b <> a then
for c := 0 to 9 do
if (c <> b) and (c <> a) then
for d := 0 to 9 do
if (d <> a) and (d <> b) and (d <> c) then
if a * b - c * d = a + b + c + d then
writeln(a, b, c, d);
end.