#include typedef struct tree { long long v; struct tree *p; } tree; tree *get_root (tree *t) { if (t == NULL || t->p == NULL) { return t; } t->p = get_root(t->p); return t->p; } int main () { int n = 0; int m = 0; long long a = 0LL; int u = 0; int v = 0; int res = 0; long long ans = 1LL; long long mod_num = 998244353LL; tree t[200000] = {}; res = scanf("%d", &n); res = scanf("%d", &m); for (int i = 0; i < n; i++) { res = scanf("%lld", &a); t[i].v = a; t[i].p = NULL; } for (int i = 0; i < m; i++) { tree *rt1 = NULL; tree *rt2 = NULL; res = scanf("%d", &u); res = scanf("%d", &v); u--; v--; rt1 = get_root(t+u); rt2 = get_root(t+v); if (rt1 != rt2) { rt1->v += rt2->v; rt1->v %= mod_num; rt2->p = rt1; } } for (int i = 0; i < n; i++) { tree *rt = get_root(t+i); ans *= rt->v; ans %= mod_num; } printf("%lld\n", ans); return 0; }