Because Nuremberg has an extensive public transportation system, you will be using the subway for traveling. The subway net is quite big, but is still fairly easily maneuvered because it is shaped like a tree. In other words, there is always a unique path between any pair of subway stations. (This is not quite true for the Nuremberg subway of today, but when you move here in a few years, we anticipate that it will be true.)
The input consists of several test cases. The first line of input contains an integer c (1 ≤ c ≤ 200), giving the number of test cases. Then, each test case starts with an integer n (1 ≤ n ≤ 50000), giving the number of subway stations in Nuremberg. Then follow n − 1 lines, describing the subway net. Each of these lines contains three integers a, b, and t (1 ≤ a, b ≤ n, and 1 ≤ t ≤ 300), indicating that stations a and b are adjacent and that it takes t seconds to travel between them. This is followed by a line containing an integer m (0 ≤ m ≤ n), denoting the number of stations which you want to go to regularly. Then follow m lines. Each of these lines contains two integers a and f (1 ≤ a ≤ n, 1 ≤ f ≤ 500), where a is the station you want to visit and f is the number of times you want to visit this station in a year. No station will occur in this list more than once.
For each test case, first output a line containing the number of seconds spent in traffic during a year, provided you choose an optimal place to live. Following this line, output a line giving all optimal choices of subway stations, separated by single spaces and in increasing order.