Bugcat Capoo planted an apple tree at his doorstep, which has a total of n nodes, and on the i-th node, an apple of size ai grows. Capoo observes and records the growth of the apples every day. He discovers that:
On the i-th day, if it's raining, all apples of size xi on the chain from node ui to node vi on the tree would grow by 1 unit;
If it's cloudy, all apples of size xi on the chain from node ui to node vi on the tree would shrink by 1 unit;
If it's sunny, then Capoo goes out to check the quality of the apples on the tree. Capoo believes that only apples exceeding size yi are up to standard apples. He would climb from node ui to node vi on the tree, checking all the apples along the path. When Capoo continuously encounters li qualifying apples, he gets very happy and records the distance from the starting position pi to the starting node ui,then stops checking. Otherwise, if there is no set of li consecutive up-standard apples on the entire path,Capoo gets disappointed and creates a scene.
However, Capoo inadvertently lost all the records of pi. Now, he comes to you with growth records of a total of m days, hoping to find out the distance disi from the recorded position pi to the starting point that he recorded each sunny day he went out to inspect, or to confirm if such a position does not exist.
Formally speaking, for an unrooted tree (V, E) of size n with node i having a weight of ai, you need to support the following operations:
If we represent the path from ui to vi on the tree as
pathT (ui, vi) = {p0, p1, · · · , pk|p0 = u, pk = v,(pi, pi+1) ∈ E}
That is, we use pi to represent the i-th point on the path, then operations can be expressed as:
• 1 ui vi xi, for each point pj satisfying apj = xi, update apj to apj + 1
• 2 ui vi xi, for each point pj satisfying apj = xi, update apj to apj − 1
• 3 ui vi li yi, seek the minimum j that satisfies ∀k ∈ [0, li), apj+k ≥ yi