#include <bits/stdc++.h>
using namespace std;
vector<int> g[100010];
struct node {
  long long w, tag;
} A[100010 * 4];
int n, q, root = 1, dfn = 0;
int w[100010], d[100010], fa[100010][22], to[100010], rk[100010], L[100010],
    R[100010];
void push_up(int rt) { A[rt].w = A[(rt << 1)].w + A[(rt << 1 | 1)].w; }
void push_down(int rt, int l, int r) {
  A[(rt << 1)].tag += A[rt].tag;
  A[(rt << 1 | 1)].tag += A[rt].tag;
  A[rt].w += A[rt].tag * (long long)(r - l + 1);
  A[rt].tag = 0;
}
void build(int rt, int l, int r) {
  if (l == r) {
    A[rt].w = w[rk[l]];
    return;
  }
  int mid = (l + r) >> 1;
  build((rt << 1), l, mid);
  build((rt << 1 | 1), mid + 1, r);
  push_up(rt);
}
void dfs(int now, int f) {
  to[now] = ++dfn;
  rk[dfn] = now;
  L[now] = dfn;
  d[now] = d[f] + 1;
  fa[now][0] = f;
  for (int i = 1; i <= 20; i++) fa[now][i] = fa[fa[now][i - 1]][i - 1];
  L[now] = R[now] = to[now];
  for (int i = 0; i < g[now].size(); i++) {
    int son = g[now][i];
    if (son != f) {
      dfs(son, now);
    }
  }
  R[now] = dfn;
}
void jump(int &x, int c) {
  for (int i = 0; i <= 20; i++) {
    if (c & 1) x = fa[x][i];
    c >>= 1;
  }
}
int lca(int x, int y) {
  if (d[x] < d[y]) swap(x, y);
  jump(x, d[x] - d[y]);
  if (x == y) return x;
  for (int i = 20; i >= 0; i--)
    if (fa[x][i] != fa[y][i]) {
      x = fa[x][i];
      y = fa[y][i];
    }
  return fa[x][0];
}
int check_son(int u, int v) {
  if (lca(u, v) == u) return 1;
  return 0;
}
void change(int rt, int l, int r, int L, int R, int x) {
  if (l >= L && r <= R) {
    A[rt].tag += x;
    long long tmp = x * (long long)(r - l + 1);
    while (rt) {
      rt >>= 1;
      A[rt].w += tmp;
    }
    return;
  }
  int mid = (l + r) >> 1;
  if (L <= mid) change((rt << 1), l, mid, L, R, x);
  if (R > mid) change((rt << 1 | 1), mid + 1, r, L, R, x);
}
long long query(int rt, int l, int r, int L, int R) {
  if (l >= L && r <= R) return A[rt].w + A[rt].tag * (long long)(r - l + 1);
  int mid = (l + r) >> 1;
  long long sum = 0;
  push_down(rt, l, r);
  if (L <= mid) sum += query((rt << 1), l, mid, L, R);
  if (R > mid) sum += query((rt << 1 | 1), mid + 1, r, L, R);
  return sum;
}
void Change_root(int v) { root = v; }
void Change(int u, int v, int x) {
  int now = lca(u, v);
  if (!check_son(now, root)) {
    change(1, 1, n, L[now], R[now], x);
    return;
  }
  change(1, 1, n, 1, n, x);
  int a = lca(root, u), b = lca(root, v);
  if (d[a] > d[b])
    u = a;
  else
    u = b;
  v = root;
  if (u == v) return;
  jump(v, d[v] - d[u] - 1);
  change(1, 1, n, L[v], R[v], -x);
}
long long Query(int v) {
  if (!check_son(v, root)) return query(1, 1, n, L[v], R[v]);
  int u = root;
  if (u == v) return query(1, 1, n, 1, n);
  jump(u, d[u] - d[v] - 1);
  return query(1, 1, n, 1, n) - query(1, 1, n, L[u], R[u]);
}
int main() {
  cin >> n >> q;
  for (int i = 1; i <= n; i++) scanf("%d", &w[i]);
  for (int i = 1; i < n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    g[x].push_back(y);
    g[y].push_back(x);
  }
  dfs(1, 0);
  build(1, 1, n);
  for (int i = 1; i <= q; i++) {
    int k, u, v, x;
    scanf("%d", &k);
    if (k == 1) {
      scanf("%d", &v);
      Change_root(v);
    }
    if (k == 2) {
      scanf("%d%d%d", &u, &v, &x);
      Change(u, v, x);
    }
    if (k == 3) {
      scanf("%d", &v);
      printf("%I64d\n", Query(v));
    }
  }
  return 0;
}
