PROGRAM HANOI_TORONY(OUTPUT);

USES CRT;

PROCEDURE HANOI(N,I,J:INTEGER);
BEGIN
   IF N = 1 THEN
      WRITELN(I,'-->',j)
   ELSE
      BEGIN
      HANOI(N-1,I,6-(I+J));
      WRITELN(I,'-->',J);
      HANOI(N-1,6-(I+J),J);
      END;
END;

BEGIN
CLRSCR;
HANOI(5,1,2);
END.

