Please subscribe to the official Codeforces channel in Telegram via the link: https://t.me/codeforces_official.
×

Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ACM-ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

No tag edit access

E. Jamie and Tree

time limit per test

2.5 secondsmemory limit per test

256 megabytesinput

standard inputoutput

standard outputTo your surprise, Jamie is the final boss! Ehehehe.

Jamie has given you a tree with *n* vertices, numbered from 1 to *n*. Initially, the root of the tree is the vertex with number 1. Also, each vertex has a value on it.

Jamie also gives you three types of queries on the tree:

1 *v* — Change the tree's root to vertex with number *v*.

2 *u* *v* *x* — For each vertex in the subtree of smallest size that contains *u* and *v*, add *x* to its value.

3 *v* — Find sum of values of vertices in the subtree of vertex with number *v*.

A subtree of vertex *v* is a set of vertices such that *v* lies on shortest path from this vertex to root of the tree. Pay attention that subtree of a vertex can change after changing the tree's root.

Show your strength in programming to Jamie by performing the queries accurately!

Input

The first line of input contains two space-separated integers *n* and *q* (1 ≤ *n* ≤ 10^{5}, 1 ≤ *q* ≤ 10^{5}) — the number of vertices in the tree and the number of queries to process respectively.

The second line contains *n* space-separated integers *a*_{1}, *a*_{2}, ..., *a*_{n} ( - 10^{8} ≤ *a*_{i} ≤ 10^{8}) — initial values of the vertices.

Next *n* - 1 lines contains two space-separated integers *u*_{i}, *v*_{i} (1 ≤ *u*_{i}, *v*_{i} ≤ *n*) describing edge between vertices *u*_{i} and *v*_{i} in the tree.

The following *q* lines describe the queries.

Each query has one of following formats depending on its type:

1 *v* (1 ≤ *v* ≤ *n*) for queries of the first type.

2 *u* *v* *x* (1 ≤ *u*, *v* ≤ *n*, - 10^{8} ≤ *x* ≤ 10^{8}) for queries of the second type.

3 *v* (1 ≤ *v* ≤ *n*) for queries of the third type.

All numbers in queries' descriptions are integers.

The queries must be carried out in the given order. It is guaranteed that the tree is valid.

Output

For each query of the third type, output the required answer. It is guaranteed that at least one query of the third type is given by Jamie.

Examples

Input

6 7

1 4 2 8 5 7

1 2

3 1

4 3

4 5

3 6

3 1

2 4 6 3

3 4

1 6

2 2 4 -5

1 4

3 3

Output

27

19

5

Input

4 6

4 3 5 6

1 2

2 3

3 4

3 1

1 3

2 2 4 3

1 1

2 2 4 -3

3 1

Output

18

21

Note

The following picture shows how the tree varies after the queries in the first sample.

Codeforces (c) Copyright 2010-2018 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Dec/13/2018 03:47:40 (f2).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|