#P9864. A. Xcellent Tree Query Problem

A. Xcellent Tree Query Problem

A. Xcellent Tree Query Problem

Problem Description

Given a tree consisting of nn nodes. Each node initially have a color cic_i. You are given mm commands, each of them is one of the follows:

  • 1 x1\ x: Cut the xx-th edge of the input.
  • 2 x l r v2\ x\ l\ r\ v: For every yy currently connected with xx (that is, no edges lying on the simple path from xx to yy is cut), if lcyrl\le c_y\le r, set cyc_y to vv.
  • 3 x l r3\ x\ l\ r: Count the number of yy currently connected with xx, that satisfy lcyrl\le c_y\le r.

Input

The first line of the input contains two integers nn (1n1051\leq n\leq 10^5) and mm (1m5×1051\leq m\leq 5\times 10^5). The second line contains nn integers c1,c2,,cnc_1, c_2, \dots, c_n (1cin1\leq c_i\leq n). Each of the following n1n - 1 lines contains two integers u,vu, v (1u,vn1 \le u, v \le n, uvu \ne v) - an edge of the tree. Each of the following mm lines contains one of the three commands listed above. It's guaranteed that no edges is cut twice or more. It's also guaranteed that in command of type 22 and 33, 1lrn1\le l\le r\le n, 1x,vn1\le x, v\le n.

Output

For every command of type 33, output the answer in a single line.

Sample Input

10 19
1 2 3 4 5 6 7 8 9 10
1 2
2 3
3 4
4 5
4 6
5 7
5 8
1 9
9 10
3 4 1 10
3 8 3 4
2 9 9 10 1
3 4 1 10
3 2 8 10
1 4
3 8 1 10
3 7 7 8
2 5 5 7 9
3 7 9 10
2 1 1 2 3
3 1 3 3
1 1
3 1 3 3
2 10 3 9 4
3 1 4 4
2 3 3 5 9
3 3 6 10
3 3 6 6

Sample Output

10
2
10
1
3
2
2
5
3
3
4
1

Source

2023“钉耙编程”中国大学生算法设计超级联赛(7)