DreamGrid will go to the bookshop tomorrow. There are $n$ books in the bookshop in total, labeled by $1,2,\dots,n$, connected by $n-1$ bidirectional roads like a tree. Because DreamGrid is very rich, he will buy the books according to the strategy below:
- Select two books $x$ and $y$.
- Walk from $x$ to $y$ along the shortest path on the tree, and check each book one by one, including the $x$-th book and the $y$-th book.
- For each book being checked now, if DreamGrid has enough money (not less than the book price), he'll buy the book and his money will be reduced by the price of the book. In case that his money is less than the price of the book being checked now, he will skip that book.
BaoBao is curious about how rich DreamGrid is. You will be given $q$ queries, in each query you will be given three integers $x_i$, $y_i$ and $z_i$. Assume DreamGrid will bring $z_i$ dollars before buying books, and will walk from $x_i$ to $y_i$, you are asked to tell BaoBao the amount of money DreamGrid will have after he checking all the visited books.