#include #include #define rep(i,n) for(int i=0;i vi; typedef vector vl; typedef vector> vvi; typedef vector> vvl; typedef pair P; typedef long double ld; using mint = modint998244353; template istream& operator>>(istream& is, vector& v){int n = v.size(); assert(n > 0); rep(i, n) is >> v[i]; return is;} template ostream& operator<<(ostream& os, const vector& v){int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "\n" : " "); return os;} template ostream& operator<<(ostream& os, const vector>& v){int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "\n" : ""); return os;} int main(){ int n, m; cin >> n >> m; vi a(n); cin >> a; dsu d(n); rep(i, m){ int u, v; cin >> u >> v; u--; v--; d.merge(u, v); } auto g = d.groups(); mint ans = 1; for(auto& v: g){ mint tmp = 0; for(int x : v) tmp += a[x]; ans *= tmp.pow(int(v.size())); } cout << ans.val(); return 0; }