#include using namespace std; const long long MOD = 998244353; struct affine{ long long a, b; affine(){ a = 1; b = 0; } affine(int a, int b): a(a), b(b){ } }; affine composite(affine A, affine B){ return affine(A.a * B.a % MOD, (A.b * B.a + B.b) % MOD); } int value(affine A, int x){ return (A.a * x + A.b) % MOD; } template struct dual_segment_tree{ int N; vector ST; function f; T E; dual_segment_tree(int n, function f, T E): f(f), E(E){ N = 1; while (N < n){ N *= 2; } ST = vector(N * 2 - 1, E); } void push(int i){ if (i < N - 1){ ST[i * 2 + 1] = f(ST[i * 2 + 1], ST[i]); ST[i * 2 + 2] = f(ST[i * 2 + 2], ST[i]); ST[i] = E; } } T operator [](int k){ int v = 0; for (int i = N / 2; i >= 1; i >>= 1){ push(v); if ((k & i) == 0){ v = v * 2 + 1; } else { v = v * 2 + 2; } } return ST[v]; } void range_apply(int L, int R, T x, int i, int l, int r){ if (r <= L || R <= l){ } else if (L <= l && r <= R){ ST[i] = f(ST[i], x); } else { push(i); int m = (l + r) / 2; range_apply(L, R, x, i * 2 + 1, l, m); range_apply(L, R, x, i * 2 + 2, m, r); } } void range_apply(int L, int R, T x){ range_apply(L, R, x, 0, 0, N); } }; int main(){ int N, Q; cin >> N >> Q; vector> E(N); for (int i = 0; i < N - 1; i++){ int A, B; cin >> A >> B; A--; B--; E[A].push_back(B); E[B].push_back(A); } vector X(N); for (int i = 0; i < N; i++){ cin >> X[i]; } vector p(N, -1); vector> c(N); queue q; q.push(0); while (!q.empty()){ int v = q.front(); q.pop(); for (int w : E[v]){ if (w != p[v]){ p[w] = v; c[v].push_back(w); q.push(w); } } } vector in(N), out(N); int t = 0; auto dfs = [&](auto dfs, int v = 0) -> void { in[v] = t; t++; for (int w : c[v]){ dfs(dfs, w); } out[v] = t; }; dfs(dfs); dual_segment_tree ST(N, composite, affine()); for (int i = 0; i < Q; i++){ int T; cin >> T; if (T == 1){ int V; cin >> V; V--; cout << value(ST[in[V]], X[V]) << endl; } if (T == 2){ int V, K; long long C, D; cin >> V >> K >> C >> D; V--; ST.range_apply(in[V], in[V] + 1, affine(C, D)); for (int w : E[V]){ ST.range_apply(in[w], in[w] + 1, affine(C, D)); } } if (T == 3){ int V; long long C, D; cin >> V >> C >> D; V--; ST.range_apply(in[V], out[V], affine(C, D)); } } }