There are several test cases.
The first line contains an integer
T![]()
(
1≤T≤8![]()
), denoting the number of test cases. Then follow all the test cases.
For each test case, the first line contains an integer
n
(1≤n≤10
5
)![]()
, denoting the number of nodes.
The second line contains
n![]()
integers, where the
i![]()
-th intger is
col
i![]()
(1≤col
i
≤n)![]()
, denoting the color of node
i![]()
at the beginning.
The third line contains
n![]()
integers, where the
i![]()
-th intger is
val
i![]()
(0≤val
i
<2
20
)![]()
, denoting the weight of node
i![]()
at the beginning.
The next
(n−1)![]()
lines describe the tree, where each line contains two integers
u![]()
and
v
(1≤u,v≤n)![]()
, representing an edge connecting node
u![]()
and node
v![]()
.
The next line contains an integer
q
(0≤q≤10
5
)![]()
, denoting the number of operations.
The next
q![]()
lines describe these operations in chronological order of occurrence, where each line contains three integers such that
● if the first integer is
1![]()
, then the following two integers are
x![]()
and
v
(1≤x≤n,0≤v<2
20
)![]()
, representing an operation of the first type, or
● otherwise the first integer is
2![]()
, and the following two integers are
x![]()
and
c
(1≤x,c≤n)![]()
, representing an operation of the second type.
It is guaranteed that the size of the standard input file does not exceed
32![]()
MiB, so you may need to use a fast approach to read the input data.