Do use segment tree
Given a tree with n (1 ≤ n ≤ 200000) nodes and a list of q (1 ≤ q ≤ 100000) queries, process the queries in order and output a value for each output query. The given tree is connected and each node on the tree has a weight w_i (−10000 ≤ w_i ≤ 10000).
Each query consists of a number t_i (t_i = 1, 2), which indicates the type of the query, and three numbers a_i, b_i and c_i (1 ≤ a_i, b_i ≤ n, −10000 ≤ c_i ≤ 10000). Depending on the query type, process one of the followings:
(t_i = 1: modification query) Change the weights of all nodes on the shortest path between a_i and b_i (both inclusive) to c_i.
(t_i = 2: output query) First, create a list of weights on the shortest path between a_i and b_i (both inclusive) in order. After that, output the maximum sum of a non-empty continuous subsequence of the weights on the list.c_i is ignored for output queries.
Input
The first line contains two integers n and q. On the second line, there are n integers which indicate w_1, w_2, ..., w_n. Each of the following n−1 lines consists of two integers s_i and e_i (1 ≤ s_i, e_i ≤ n), which means that there is an edge between s_i and e_i.
Finally the following q lines give the list of queries, each of which contains four integers in the format described above. Queries must be processed one by one from top to bottom.
Output
For each output query, output the maximum sum in one line.