#D12298. Witch Craft Moves

    ID: 10225 Type: Default 3000ms 268MiB

Witch Craft Moves

Witch Craft Moves

Problem

Aizu Magic School is a school where people who can use magic gather. Aizu Magic School has classrooms numbered from 1 to N and a corridor connecting the classrooms. You can go through the classrooms and corridors as many times as you like. In addition, Aizu Magic School has only one route that allows you to move between any classroom u and v through 0 or more classrooms and a corridor once. A magic circle is set up in each classroom. This magic square increases or decreases the magical power of those who enter the classroom each time they enter the classroom. Please answer the following two questions to help the students move.

question 1 0 A B I want you to output the remaining amount of magical power when you move from classroom A to B. Including increase / decrease in classrooms A and B. Also, the amount of magical power at the beginning of this question is 0 each time.

Question 2 1 A C The amount of increase / decrease in the magical power of classroom A changes by C.

Constraints

The input satisfies the following conditions.

  • 1 ≤ N ≤ 2000
  • 1 ≤ Ai ≤ 2000
  • 1 ≤ Bi ≤ 2000
  • 1 ≤ aj, bj ≤ N
  • 1 ≤ Q ≤ 1000000
  • -10000 ≤ Ci ≤ 10000

Input

N cost1 :: costN a1 b1 :: aN-1 bN-1 Q query1 :: queryQ

The number N of classrooms is given at the beginning of the input. The following N lines are given the amount of magical power that increases or decreases when entering each classroom. The value on the i-line corresponds to the information in the classroom on the i-th line. Corridor information is given to the following N-1 line. The corridor on the jth line represents connecting the ajth and bjth classrooms. Then the number of questions Q is given. The following Q line is given the question in the above format.

Output

Output the answer to one line for each question 1.

Example

Input

7 1 2 3 4 5 6 7 1 2 1 3 3 4 3 5 5 6 5 7 10 0 1 7 0 2 7 1 1 15 0 1 7 0 2 7 0 1 1 1 1 -15 0 1 7 0 2 7 0 1 1

Output

16 18 31 33 16 16 18 1

inputFormat

outputFormat

output the remaining amount of magical power when you move from classroom A to B. Including increase / decrease in classrooms A and B. Also, the amount of magical power at the beginning of this question is 0 each time.

Question 2 1 A C The amount of increase / decrease in the magical power of classroom A changes by C.

Constraints

The input satisfies the following conditions.

  • 1 ≤ N ≤ 2000
  • 1 ≤ Ai ≤ 2000
  • 1 ≤ Bi ≤ 2000
  • 1 ≤ aj, bj ≤ N
  • 1 ≤ Q ≤ 1000000
  • -10000 ≤ Ci ≤ 10000

Input

N cost1 :: costN a1 b1 :: aN-1 bN-1 Q query1 :: queryQ

The number N of classrooms is given at the beginning of the input. The following N lines are given the amount of magical power that increases or decreases when entering each classroom. The value on the i-line corresponds to the information in the classroom on the i-th line. Corridor information is given to the following N-1 line. The corridor on the jth line represents connecting the ajth and bjth classrooms. Then the number of questions Q is given. The following Q line is given the question in the above format.

Output

Output the answer to one line for each question 1.

Example

Input

7 1 2 3 4 5 6 7 1 2 1 3 3 4 3 5 5 6 5 7 10 0 1 7 0 2 7 1 1 15 0 1 7 0 2 7 0 1 1 1 1 -15 0 1 7 0 2 7 0 1 1

Output

16 18 31 33 16 16 18 1

样例

7
1
2
3
4
5
6
7
1 2
1 3
3 4
3 5
5 6
5 7
10
0 1 7
0 2 7
1 1 15
0 1 7
0 2 7
0 1 1
1 1 -15
0 1 7
0 2 7
0 1 1
16

18 31 33 16 16 18 1

</p>