Tree query - MarisaOJ: Marisa Online Judge

Tree query

Time limit: 1000 ms
Memory limit: 256 MB
You are given a tree with $n$ vertices, each initially labeled with the number $0$. You have been given $q$ queries, each in one of the following two forms: - `1 u d` : increase the on vertices that adjacent to $u$ by $d$. - `2 u` : find the number on vertex $u$. ### Input - The first line contains 2 integers $n, q$. - The next $n - 1$ lines, each line contains 2 integers $u, v$, there is an edge between $u$ and $v$. ### Output - Print the answer for each query of type $2$. ### Constraints - $1 \le n,q 10^5$. - $1 \le u, v \le n$. - $1 \le d \le 10^9$. ### Example Input: ``` 3 2 1 2 1 3 1 1 1 2 3 ``` Output: ``` 1 ```