{$T-}
program TOWERS_OF_HANOI;
var N,CHK:INTEGER;

procedure MOVETOWER(M,A,B,C,D: INTEGER);

begin
if M=1
then D := D + 1
else begin
  MOVETOWER(M-1,A,C,B,D);
  D := D - 1;
  MOVETOWER(M-1,B,A,C,D)
  end;
end {MOVETOWER};

begin
CHK := 0;
WRITE(OUT,'enter N:'); BREAK(OUT); READ(INP,N);
MOVETOWER(N,1,2,3,CHK);
WRITE(OUT,'I AM DONE...'); BREAK(OUT)
end.
