Journey of Recovery

You are making an international trip with several stops to blow off steam and
celebrate your progression onto the NWERC.
Since your flights are often booked with low-cost airlines, you always run the
risk of your flights being cancelled last minute leaving you stuck in the
airport. Normally this is no problem-take the next flight-but you have to
arrive at the NWERC on time.

If any one of your flights is cancelled at
the same moment you are about to depart, and all others operate as planned, you
will book a new itinerary from there to your final destination.
Assuming you always plot the fastest route, by how much will you be delayed
in the worst case?

Input
	itemize
    One line containing the number of flight connections overall,  ().
     further lines, the th of which contains four space-separated fields:
      itemize
        The code of the departure airport,  ()
        The time of departure in days, minutes, and hours, in the format ddhh:mm
              (, , ).
        The code of the arrival airport,  ()
        The time of arrival in days, minutes, and hours, in the format ddhh:mm
              (, , ).
      itemize
    One line containing the number of flight connections in your itinerary,  ().
    One line containing the  indices  of flight connections,
          in the order you plan to take them.
	itemize

  Flights always go between different airports and always strictly forward in
  time.
        For every consecutive pair  in your itinerary, the arrival time of flight
         is guaranteed to be less than or equal to the departure time of flight .

  Transfers are instantaneous-that is to say, arriving at an airport and
  departing from it in the same minute is possible. Likewise, if one planned flight
  is cancelled, you may board another departing at exactly the same time.

Output
  Output the maximum amount by which you could be delayed if any one of the given flights
  is cancelled at its moment of boarding. If you would not be delayed at all in any case
  (or can even arrive early) simply output .

  If you cannot always make it to the destination at all, output stranded instead.
