

Suppose Ninja is currently standing at X city and want to visit Y city. Let the heights of all the cities in the path from X to Y(including X and Y) are 10 20 5 30. Now these series of heights forms and alternate series. So Ninja will visit the city Y.
Some examples of alternate series are 15 4 11 8 25, 100 120 50 70 60 but the series like 3 5 4 1, 6 3 10 12 are not alternating.
1 X Y: change the height of city X to Y.
2 X Y: Check whether the path between city X to Y is alternating or not.
The first line contains two space-separated integers ‘N’ and ‘Q’ denoting the number of cities in the Ninja Land and the number of queries.
The next N-1 lines will contain two space-separated integers X and Y, denoting that there is an undirected edge between city X and city Y.
The next line contains ‘N’ space-separated integers denoting the initial heights of each city.
The next q lines contain three space-separated integers representing the queries of both types.
Output for each query of type two only, whether the path between the two cities of that query is alternating or not.
Output for each query will be printed in a separate line.
You are not required to print anything; it has already been taken care of. Just implement the function.
1 <= N,Q <= 10^5
1 <= X,Y <= N
1 <= height[i] <= 10^9
Where N is the number of cities, Q is the number of queries, X and Y represent the cities, and height[i] represents the height of the i’th city.
Time Limit: 1 sec.
We will use heavy-light decomposition to solve this problem. The idea of this algorithm is that we will try to break the given tree into some segments where we can apply the segment tree to process each query in logarithmic time.
More about this algorithm can be found at the given link:
https://cp-algorithms.com/graph/hld.html
Algorithm: