Charles is a truck driver in the city of Googleland. Googleland is built in the form of a tree with nodes, where each node represents a city and each edge represents a road between cities. The cities are numbered to . The capital of Googleland is city . Each day Charles picks up a load of weight in city and wants to deliver it to city using the simple path (which is unique) between the cities. Each road has a toll which charges amount if the weight of the load is greater than or equal to a load-limit .
Charles works for days, where for each day Charles will be given the starting city and weight of the load . For each day, find the greatest common divisor of all the toll charges that Charles pays for that day. If Charles did not have to pay in any of the tolls, the answer is .
输入格式
The first line of the input gives the number of test cases, . test cases follow.
The first line of each test case contains the integers and .
The next lines describe the roads. The -th of these lines contains the space-separated integers , , and , indicating a road between cities and with load-limit and toll charge .
The next lines describe the queries. The -th of these lines contains the space-separated integers and representing the starting city and weight of the load on the -th day.
输出格式
For each test case, output line containing Case #: followed by , where is the test case number (starting from ) and is a list of the answers for days in order, separated by spaces.