Limits 1s, 512 MB

The problem statement is simple. You are given a rooted tree (1 is the root) and every node has a cost, say CiC_i. You have to perform QQ operations. Each operation can be one of the following types.

  • Given uu, valval. you have to set Cu=valC_u = val.
  • Given uu. You have to find the Xinversion of uu.

Xinversion is almost similar to the inversion of an array. Xinversion of a node xx is the number of nodes yy inside the subtree of xx such that Cy>CxC_y > C_x.

Input

In the first line you are given two integers NN (1N1051 \leq N \leq 10^5) and QQ (1Q1051 \leq Q \leq 10^5), the number of nodes and the number of operations respectively.

The next line will contain NN integers, ii-th integer represents CiC_i (1Ci1091 \leq C_i \leq 10^9).

Each of the next N1N-1 lines will contain two integers uu, vv which means uu and vv are connected with an edge.

Each of the next QQ lines will contain one of the two types of operations:

  • 1 u val
  • 2 u

Output

For every operations of type 2, print the Xinversion of uu.

Sample

InputOutput
5 5
1 2 3 4 5
1 2
2 3
2 4
3 5
2 1
2 2
1 3 1
1 4 1
2 1
4
3
2

Submit

Login to submit.

Statistics

84% Solution Ratio
YouKnowWhoEarliest, Apr '20
Kuddus.6068Fastest, 0.1s
user.2599Lightest, 12 MB
steinumShortest, 814B
Toph uses cookies. By continuing you agree to our Cookie Policy.