program codecup2007;

{ (C) CodeCup 2007 }

const max=100000;

type connection=record
                  from,towards: integer;
                  kind: char
                end;

var AmIFugitive: boolean;           {true: Fugitive; false: Detectives}
    inputline: string;              {inputline from standard input}
    cities: integer;                {number of cities}
    connections: longint;           {number of connections}
    turns: integer;                 {the number of turns}
    c: array[1..max] of connection; {all connections}
    d: array[1..4] of integer;      {the detectives}
    fug: integer;                   {the fugitive}

procedure ReadGraph;
var f: text;
begin
  assign(f,'connect.txt');
  reset(f);

  { read and Process the file connect.txt

    TODO }

  close(f)
end;

procedure GetRole;
begin
  readln(inputline);
  AmIFugitive:=inputline[1]='F'
end;


procedure ReadInputLine;
begin
  readln(inputline)
end;

procedure PlaceDetectives;
begin
  { get an Initial position for the Detectives.

    TODO }
end;

procedure ReadFugitive;
begin
  readln(fug)
end;

procedure ProcessInputline;
var transport: char;
    error: integer;
begin
  transport:=inputline[1];
  if (turns mod 5)=0 then
  begin
    delete(inputline,1,2);
    val(inputline,fug,error)
  end;

  { extract more information about possible Positions.

    TODO }
end;

procedure MoveDetectives;
begin
  { find a new place for the Detective and output their Postions.

    TODO }
end;

procedure Catch;
begin
  PlaceDetectives;
  ReadFugitive;
  turns:=1;
  repeat
    ReadInputLine;
    if inputline[1]<>'Q' then
    begin
      ProcessInputline;
      MoveDetectives
    end
  until inputline[1]='Q'
end;

procedure ReadDetectives;
var i: integer;
begin
  val(inputline,d[1],i);
  for i:=2 to 4 do readln(d[i])
end;

procedure PlaceFugitive;
begin
  { find an initial place for the fugitive and output this position

    TODO }
end;

procedure MoveFugitive;
begin
  { decide the way th fugitive is going to travel and output Ticket
    and Destination.

    TODO }
end;

procedure Run;
begin
  ReadDetectives;
  PlaceFugitive;
  turns:=1;
  repeat
    MoveFugitive;
    ReadInputLine;
    if inputline[1]<>'Q' then ReadDetectives
  until inputline[1]='Q'
end;

begin
  GetRole;
  ReadGraph;
  if AmIFugitive then Run else Catch
end.


syntax highlighted by Code2HTML, v. 0.9.1