Bus or Train ------------ Robert and Stephen are planning a month long trip through Western Europe. They have already decided which cities they want to visit. Because of Robert's fear of flying, they shall only use buses or trains. Given their limited budget, they can only afford a Eurail pass to travel by train or a Euroline pass to travel by bus. Since they want to minimize the amount of time they spend in trains or buses, they are also interested in the minimal distance that needs to be traveled by train or bus to get from one destination to another. Can you help them by calculating those distances? Input ----- The input may contain multiple test cases. The first line of each test case contains two integers N (1 <= N <= 100), and M (0 <= M <= 10000) where N indicates the number of cities Robert and Stephen plan to visit and M represents the number of train/bus connections between those cities. The next M lines of the test case describe the train/bus connections. Each line has the following form. o d m where the integer o (1 <= o <= N) represents the origin of the connection, the integer d (1 <= d <= N) represents the destination of the connection, and the string m represents the mode of the connection: B - bus only T - train only BT - bus and train For example, 1 2 150 BT tells us that Robert and Stephen can travel from 1 to 2 by either bus or train and the distance is 150 kilometers. The next line of the test case contains an integer Q (0 <= Q <= N * N). The next Q lines represent Robert and Stephen's queries. Each query consists of an origin o (1 <= o <= N) and destination d (1 <= d <= N). The input will terminate with two zeros for N and M. Output ------ For each test case, print a line consisting of "Case n", where n is the number of the test case, and produce one line of output for each query of that test case. For a query "o d", print the smallest distance from o to d by bus and by train. If there is no way to get from o to d, print "no route". For the exact format of the output, see the sample output below. Sample Input ------------ 1 0 1 1 1 5 8 1 2 100 T 2 4 100 T 4 3 100 T 3 1 100 T 1 5 60 BT 5 2 60 B 5 3 60 B 5 4 60 B 4 1 2 1 3 1 4 2 1 0 0 Sample Output ------------- Case 1 Bus: 0, train: 0 Case 2 Bus: 120, train: 100 Bus: 120, train: 300 Bus: 120, train: 200 Bus: no route, train: 300