Chef, Leonardo And Queries

All submissions for this problem are available.
Read problems statements in Mandarin chinese, Russian and Vietnamese as well.
Chef has a tree with N nodes numbered 1 through N. Initially, each node has value 0.
Chef's best friend Leonardo loves queries on trees. He asked Chef to perform Q queries. Each query is of one of the following two types:
 1 v k a b: Consider f(0) = a, f(1) = b, f(i) = f(i  1) + f(i  2) for i ≥ 2. For each node u of the tree, let d be the distance (in edges) from v to u. Then, if d ≤ k, Chef must add f(d) to the value of node u.
 2 v: Print the value of node v modulo 10^9 + 7.
Help Chef perform Leonardo's queries!
Input
 The first line of the input contains one integer T denoting the number of test cases.
 The first line of each test case contains two spaceseparated integers N and Q.
 Each of the next N1 lines contains two spaceseparated integers x and y denoting an edge between nodes x and y.
 Q lines follow. Each of these lines describes one query in the format above.
Output
For each query of type 2, print the answer to it on a separate line.
Constraints
 1 ≤ T ≤ 150
 1 ≤ N, Q ≤ 300,000
 1 ≤ sum of N over all testcases ≤ 300,000
 1 ≤ sum of Q over all testcases ≤ 300,000
 1 ≤ v ≤ N
 0 ≤ k ≤ N
 0 ≤ a, b ≤ 1,000,000,000
Subtasks
Subtask #1 (15 points):
 sum of all N ≤ 3000
 sum of all Q ≤ 3000
Subtask #2 (85 points): original constraints
Example
Input: 1 6 5 4 5 1 5 5 2 3 4 6 1 1 2 0 3 3 2 2 1 4 2 1 5 1 1 2 5 4 2 4 Output: 3 10
Author:  kefaa 
Editorial  https://discuss.codechef.com/problems/CHEFFIB 
Tags  dec17, kefaa 
Date Added:  23112017 
Time Limit:  4 sec 
Source Limit:  50000 Bytes 
Languages:  C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, kotlin, PERL6, TEXT, SCM chicken, CLOJ, COB, FS 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions