#include #include using namespace std; using namespace atcoder; struct Fast { Fast() { std::cin.tie(nullptr); ios::sync_with_stdio(false); cout << setprecision(10); } } fast; #define rep(i, a, b) for (int(i) = (a); (i) < (int)(b); (i)++) using mint = modint998244353; int main() { int n, m; cin >> n >> m; vector a(n); rep(i, 0, n) cin >> a[i]; dsu uf(n); rep(i, 0, m) { int u, v; cin >> u >> v; u--; v--; uf.merge(u, v); } mint ans = 1; for (auto s : uf.groups()) { mint sum = 0; for (auto x : s) sum += a[x]; ans *= sum.pow(s.size()); } cout << ans.val() << endl; }