New Year Tree

hard
<a href="https://codeforces.com/contest/620/problem/E">https://codeforces.com/contest/620/problem/E</a>

Input Format

.

Output Format

.

Constraints

.

Notice

.

Example

Input
7 10
1 1 1 1 1 1 1
1 2
1 3
1 4
3 5
3 6
3 7
1 3 2
2 1
1 4 3
2 1
1 2 5
2 1
1 6 4
2 1
2 2
2 3
Output
2
3
4
5
1
2
Previous
Subtree Sum
Next
Lca - Lowest Common Ancestor - Euler Tour

Related Questions