#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; const int MaxN = 1e5 + 10; const int MOD = 1e9 + 7; const int INF = 1e9; int n, q, pred[MaxN], z; long long w[MaxN]; vector < int > g[MaxN]; set < int > ch[MaxN]; void dfs(int v, int p) { z++; for (auto to : g[v]) { if (to == p) { continue; } pred[to] = v; dfs(to, v); ch[v].insert(to); } } long long get(int v) { long long res = w[v]; for (auto to : ch[v]) { res += get(to); } return res; } bool isParent(int u, int v) { while (u != 0) { if (u == v) { return true; } u = pred[u]; } return false; } void go(int v, int x) { w[v] += x; for (auto to : ch[v]) { go(to, x); } } int main() { // freopen("input.txt", "r", stdin); scanf("%d%d", &n, &q); assert (1 <= n && n <= 100000); assert (1 <= q && q <= 100000); for (int i = 1; i <= n; ++i) { scanf("%d", &w[i]); assert (1 <= w[i] && w[i] <= 100000); } for (int i = 1; i < n; ++i) { int x, y; scanf("%d%d", &x, &y); assert (x != y); assert (1 <= x && x <= n); assert (1 <= y && y <= n); g[x].push_back(y); g[y].push_back(x); } dfs(1, 0); assert (z == n); while (q --> 0) { int type; scanf("%d", &type); assert (1 <= type && type <= 3); if (type == 1) { int v; scanf("%d", &v); assert (1 <= v && v <= n); printf("%lld\n", get(v)); } else if (type == 2) { int v, x; scanf("%d%d", &v, &x); assert (1 <= v && v <= n); assert (1 <= x && x <= 100000); go(v, x); } else { int u, v; scanf("%d%d", &u, &v); assert (1 <= u && u <= n); assert (1 <= v && v <= n); if (isParent(u, v) || isParent(v, u)) { printf("-1\n"); } else { ch[pred[u]].erase(u); ch[pred[v]].erase(v); swap(pred[u], pred[v]); ch[pred[u]].insert(u); ch[pred[v]].insert(v); } } } return 0; }