The first line consists of two integers,and
![]()
, representing the number of nodes in the tree and the number of operations, respectively.
The second line containsintegers,
![]()
, representing the initial node weights.
The third line containsintegers, where the
th integer,
![]()
, represents the existence of an edge between the
th node and the
th node.
Following arelines, each representing an operation:
For each operation, the first integer of the line,![]()
, denotes the type of operation.
If , then the next three integers,
,
, and
, represent the two endpoints of the covered chain and the assigned weight for that chain.
If , then the next integer,
, represents the root node of the subtree for which a query is required.
For each query, output a single line containing an integer representing the answer to that query.
For Sample 3, in the first query, after the first two coverings, the node weights of the tree become, and the valid point pairs in subtree 3 are
.
In the second query, after the first three coverings, the node weights of the tree become, and the valid point pairs in subtree 1 are
.