#include using namespace std; const long long MOD = 998244353; 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); vector d(N, 0); 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); d[w] = d[v] + 1; q.push(w); } } } for (int i = 0; i < Q; i++){ int T; cin >> T; if (T == 1){ int V; cin >> V; V--; cout << X[V] << endl; } if (T == 2){ int V, K; long long B, C; cin >> V >> K >> B >> C; V--; X[V] = (X[V] * B + C) % MOD; for (int w : E[V]){ X[w] = (X[w] * B + C) % MOD; } } if (T == 3){ int V; long long B, C; cin >> V >> B >> C; V--; auto dfs = [&](auto dfs, int v) -> void { X[v] = (X[v] * B + C) % MOD; for (int w : c[v]){ dfs(dfs, w); } }; dfs(dfs, V); } if (T == 4){ int U, V; long long B, C; cin >> U >> V >> B >> C; U--; V--; while (true){ if (U == V){ X[U] = (X[U] * B + C) % MOD; break; } if (d[U] > d[V]){ swap(U, V); } X[V] = (X[V] * B + C) % MOD; V = p[V]; } } } }