Matcom Online Grader
Faculty of Mathematics and Computer Science of University of Havana
ℹ️ We've recently migrated MOG to a new server with a different grader. As a result, some features—especially those related to submission evaluation—might not work correctly. If you encounter any issues, please report them by clicking the exclamation icon in the bottom right corner of the website.
Are you sure you want to participate in this contest ?
If you select a team then virtual participation for other team members will be disabled. So, pick one if and only if your teammates are ready to compete with you.
Given a tree with n vertices numbered from 1 to n. Each vertex i has an initial value Wi. You need to perform two types of queries:
add(v, x): Increase the value for all neighbors of v with x. It is guaranteed that 1≤v≤n and 1≤x≤1000.
get(v): Print the value of vertex v (1≤v≤n).
Input
The first line of input contains the number of vertices (1≤n≤105).
The following line contains n integers Wi (1≤Wi≤1000) separated by a whitespace with the initial values of the vertices.
The following n−1 lines contain two integers u and v (1≤u,v≤n, u≠v) separated by a whitespace, indicating that there is an edge between vertices u and v.
The next line contains the number of queries q (1≤q≤2×105).
The following q lines contain the description of the queries, in the format explained above.
Output
For each query of type 2, print the value of the vertex v in each case.