Junior 5 — Pursuit of Knowledge
The programming club at Don Mills has been booming lately, and so Griffy has decided to install a system to figure out the path that students should take to reach the club room (which is not necessarily held in the same room every time). He hopes that this act of kindness will weaken Timothy Li's defenses so he will be able to beat him up at tic-tac-toe. There are rooms numbered from to , and one way hallways that connect two locations. Each hallway takes minutes to traverse. Given queries in the form
a b, where is not equal to , find the least amount of time needed to go from room to room . If it is not possible to get from to , output
Not enough hallways!.
First line, three integers , , .
Next lines, two integers
a b on each line describing a one way hallway from to .
Line , one integer .
Lines , two integers
a b the query rooms.
One line for each query, the shortest amount of time taken to go from room to room .
7 6 8 2 3 5 7 1 7 3 4 4 3 1 2 3 1 7 4 2 1 4
8 Not enough hallways! 24