unit fjf218u;

interface

type
  ppil = ^pil;
  pil = ^il;
  il  = record
    Next : pil;
    v    : Integer
  end;

  pm = ^m;
  m = object
    Next : pm;
    constructor Init;
    destructor Done; virtual;
  end;

  e = object (m) end;
  pe = ^e;

procedure dil (i : pil);

implementation

procedure dil (i : pil);
var t : pil;
begin
  while i <> nil do
    begin
      t := i;
      i := i^.Next;
      Dispose (t)
    end
end;

constructor m.Init;
begin
end;

destructor m.Done;
begin
end;

end.

unit fjf218v;

interface

uses fjf218u;

type
  y = object (e)
    jc : pil;
    constructor Init (ajc : pil);
    destructor Done; virtual;
  end;

  py = ^y;

implementation

constructor y.Init (ajc : pil);
begin
  jc := ajc
end;

destructor y.Done;
begin
  dil (jc)
end;

end.

program fjf218;

uses fjf218u, fjf218v;

var
  msg : pm;
  p, q : pil;

begin
  New (q);
  New (q^.Next);
  q^.v := Ord('O');
  q^.Next^.v := Ord('K');
  q^.Next^.Next := nil;
  msg := New (py, Init (q));
  p := y(msg^).jc;
  while p <> nil do
    begin
      write (chr (p^.v));
      p := p^.next
    end;
  writeln
end.
