A group of ants is really proud because they built a magnificent and large colony. However, the enormous size has become a problem, because many ants do not know the path between some parts of the colony. They desperately need your help!
The colony of ants was made as a series of $N$ anthills, connected by tunnels. The ants, obsessive as they are, numbered the anthills sequentially as they built them. The first anthill, numbered $0$, did not require any tunnel, but for each of the subsequent anthills, $1$ through $N - 1$, the ants also built a single tunnel that connected the new anthill to one of the existing anthills. Of course, this tunnel was enough to allow any ant to go to any previously built anthill, possibly passing through other anthills in its path, so they did not bother making extra tunnels and continued building more anthills.
Your job is, given the structure of the colony and a set of queries, calculate for each query the shortest path between pairs of anthills. The length of a path is the sum of the lengths of all tunnels that need to be traveled.
Each test case is given using several lines. The first line contains an integer $N$ representing the number of anthills in the colony ($2 \leq N \leq 10^5$). Each of the next $N - 1$ lines contains two integers that describe a tunnel. Line $i$, for $1 \leq i \leq N - 1$, contains $A_i$ and $L_i$ , indicating that anthill $i$ was connected directly to anthill $A_i$ with a tunnel of length $L_i$ ($0 \leq A_i \leq i - 1$ and $1 \leq L_i \leq 10^9$). The next line contains an integer $Q$ representing the number of queries that follow ($1 \leq Q \leq 10^5$). Each of the next $Q$ lines describes a query and contains two distinct integers $S$ and $T$ ($0 \leq S, T \leq N - 1$), representing respectively the source and target anthills.
The last test case is followed by a line containing one zero.