import std; void main () { int N, M; readln.read(N, M); int[] A = readln.split.to!(int[]); int[][] graph = new int[][](N, 0); foreach (_; 0..M) { int U, V; readln.read(U, V); U--, V--; graph[U] ~= V; graph[V] ~= U; } solve(N, M, A, graph); } void solve (int N, int M, int[] A, int[][] graph) { // 連結成分を列挙していけばよいですね~ const long MOD = 998244353; int[] visited = new int[](N); DList!int Q; long[] SumOfComponent; int idx = 0; visited[] = -1; foreach (i; 0..N) { if (visited[i] != -1) continue; visited[i] = idx; Q.insertBack(i); SumOfComponent ~= A[i]; SumOfComponent[idx] %= MOD; while (!Q.empty) { auto head = Q.front; Q.removeFront; foreach (to; graph[head]) { if (visited[to] != -1) continue; visited[to] = idx; (SumOfComponent[idx] += A[to]) %= MOD; Q.insertBack(to); } } idx++; } long ans = 1; foreach (x; 0..N) { ans *= SumOfComponent[ visited[x] ]; ans %= MOD; } writeln(ans); } void read(T...)(string S, ref T args) { auto buf = S.split; foreach (i, ref arg; args) { arg = buf[i].to!(typeof(arg)); } }