There are three sections in the input file, the first lists the cities, the second lists the roads, and the third lists the queries.
The first line of input is the number of cities, c, followed by c lines each containing the name of a city. There is no whitespace in a city name.
The next line is the number of roads, r, followed by r lines describing a road. Each road description has the following form:
< RoadName > < CityA > < ABDistance > < ABTime > < CityB > [< BCDist > < BCTime > < CityC > [...]]
There is no whitespace in a road's name. Roads may pass through any number of cities. The cities appear in the order the road passes through them. No road passes through the same city multiple times. Roads are bidirectional. The distance and time (both real numbers) it takes to follow a road between each pair of cities is the distance and time listed between those two names.When following a road between multiple cities (A to C, for example), the distance and time is cumulative for all steps along the path.
The remainder of the lines in the file each list one query. Queries are of the form:
< querytype > < origin > < destination >
Querytype is one of time, distance, or turns and the origin and destination are the names of cities.
The queries end at end-of-file.