Hongjun and the Tree

Process subtree updates that add a distance-dependent value to each vertex, answering point-weight queries modulo 1e9+7.

Hard8TreeDFSPrefix sumDynamic programmingNo attempts yetTime limit2sMemory limit512 MB

Problem

You are given a tree with NN vertices rooted at vertex 1. Every vertex starts with weight 0.

Process QQ queries in the given order. There are two kinds.

  • Type 1, written as 1 v x k: add xx to the weight of vertex vv, and add xi×kx - i \times k to the weight of every vertex that lies in the subtree of vv at distance ii from vv. (1vN1 \le v \le N, 0x,k<109+70 \le x, k < 10^9+7)
  • Type 2, written as 2 v: print the current weight of vertex vv modulo 109+710^9+7. (1vN1 \le v \le N)

A weight can become negative. The answer to a type 2 query is always a residue between 0 and 109+610^9+6.

Input

The first line contains the number of vertices NN and the number of queries QQ. (1N3000001 \le N \le 300\,000, 1Q3000001 \le Q \le 300\,000)

The second line contains N1N-1 integers p2,p3,,pNp_2, p_3, \dots, p_N. Here pkp_k is the parent of vertex kk and satisfies 1pk<k1 \le p_k < k. When NN is 1, the second line is empty.

Each of the next QQ lines contains one query. The first integer on a line is the query type, followed by the integers that type takes.

Output

For each type 2 query, print its answer on its own line, in input order.