Each test contains multiple test cases. The first line contains the number of test cases(
). The description of the test cases follows.
The first line of each test case contains an integer(
), representing the number of nodes in the tree.
The nextlines each contain three integers
(
), representing that the parent of node
is
, and the
-th query is
.
It is guaranteed that:
For each test case, the edges form a rooted tree.
For each test case, for any , there does not exist
such that
and
.
The sum of over all test cases does not exceed
.
For each test case, output
integers in one line. The
-th integer represents your answer to the
-th query.