SP19153 INS14L - Rooted Trees
Description
Digo is given a rooted tree where nodes are numbered from 1 to N (1 is the root node) and asked some queries on it.
There are two types of queries
1) Given node number U, two integers X, K which means add X to the given node , X+K to its children , X+2\*K to children of its children and so on..
2) Given a node number U print the sum of nodes in the subtree rooted at U (including node U).
Since the answer can be too long, print the answer 10^9 + 7
Initially each node contains zero.
Input Format:
First line contains a single integer N denoting the number of nodes in the tree.
Next N-1 lines denotes the parent node of nodes 2 to N. (1 is the root node it has no parent)
Next line contains M (Number of queries).
In each of the next M lines first integer is T which means the type of the query.
If T is ,1 it is followed by three integers U, X, K as explained in the question.
If T is 2, it is followed by a single integer U.
Output Format:-
For each query of type 2, output a single line containing the required answer.
Constraints:-
1
Input Format
N/A
Output Format
N/A