Type 
  StackP = ^ StackT;
  StackT = Record
    v1,v2,v3 : integer;
    next : stackp;
  End;
{----------------------}
  Stack = object
    StackTop : StackP;
    Constructor Init;
    Destructor Done;
    function top(var v1,v2,v3 : integer):boolean;
    function pop(var v1,v2,v3 : integer):boolean;
    procedure push(v1,v2,v3 : integer);
  End;
{----------------------}
Constructor stack.init;
Begin
  StackTop:=Nil;
End;
{----------------------}
Procedure stack.push;
var
  s : stackp;
Begin
  new(s); 
  s^.next:=stacktop;
  stacktop:=s;
  stacktop^.v1:=v1;
  stacktop^.v2:=v2;
  stacktop^.v3:=v3;
End;
{----------------------}
Destructor stack.Done;
var
  s : stackp;
Begin
  while stacktop<>nil do begin
    s:=stacktop;
    stacktop:=stacktop^.next;
    dispose(s);
  end;
End;
{----------------------}
Function stack.pop;
var
  s : stackp;
Begin
  if stacktop=nil then begin
    pop:=false;
    exit;
  end
  else pop:=true;
  v1:=stacktop^.v1;
  v2:=stacktop^.v2;
  v3:=stacktop^.v3;
  s:=stacktop;
  stacktop:=stacktop^.next;
  dispose(s);
End;
{----------------------}
Function stack.top;
var
  s : stackp;
Begin
  if stacktop=nil then begin
    top:=false;
  end
  else top:=true;
  v1:=stacktop^.v1;
  v2:=stacktop^.v2;
  v3:=stacktop^.v3;
End;



