There is a tree with n(n The i-th node has a value val[i](0 Define the value of a connected component as the product of each node's value. White Cloud has 3 types of operation. The first operation is to change a node's value. The second operation is to change a node's father. The third operation is to give 2 integers b and c, denoting querying the sum of value of all connected components which contains node b of size c.
输入描述:
The first line of input contains 2 integers n and m(n,mIn the next line, there are n integers, denoting val[1..n].In the next line, there are n-1 integers, denoting the father from the 2-th node to the n-th node.In the next m lines, the first number a is the type of operation.if a=0, the next 2 integers b and c(1 if a=1, the next 2 integers b and c(1 if a=2, the next 2 integers b and c(1 = b = n,0c = 10) denote querying the sum of value of all connected components which contains node b of size c.


输出描述:
For each operation, if a=2, print a single line containing the answer modulo 1000000000+7.
示例1

输入

3 3
1 2 3
1 1
2 1 2
2 1 3
2 2 3

输出

5
6
6
加载中...