C. Fare
time limit per test
3 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

There are $$$N$$$ cities in the country of Drevlyandia, and each is numbered from $$$1$$$ to $$$N$$$. It is also known that there are bidirectional roads between some of the cities; besides, from each city, you can get to any other in the only way, possibly by passing through other cities. In addition, you need to pay a certain amount for driving on the road. Traveling salesman Alexey has to make $$$Q$$$ trips between pairs of cities, and he wants to find out how much money he has to spend on each trip. However, the fare is calculated by a very strange formula: all driving costs are multiplied, and then the result is taken modulo $$$10^9 + 7$$$. Since Alexey is very bad at counting, he asks you to help him. Your task is to write a program that calculates the cost of each Alexey's trip.

Input

The first line consists of the number $$$N$$$ $$$(1 \le N \le 2 \cdot 10^5)$$$ – quantity of cities in Drevlyandia.

The next $$$N - 1$$$ lines consist of information about roads. Each line has numbers $$$u, v, w~(1\le u, v \le N, 1 \le w \le 10^9, u \ne v)$$$ – numbers of the cities connected by bidirectional roads and the road fare.

The $$$(N+1)$$$-th line consists of the number $$$Q$$$ $$$(1 \le Q \le 2 \cdot 10^5)$$$ – the number of Alexey's trips.

In the following $$$Q$$$ lines, there are pairs of numbers $$$a$$$ and $$$b$$$ $$$(1 \le a, b \le N, a \ne b)$$$ – the numbers of the cities between which you should calculate road fares.

Output

Output $$$Q$$$ lines – road fares between the cities by the formula described in the problem description.

Example
Input
6
1 3 3
3 2 5
4 5 6
6 4 9
4 1 10
5
1 3
3 2
5 6
2 4
2 6
Output
3
5
54
150
1350