#include using namespace std; using ll=long long; int const mod=998244353; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int N,M; cin>>N>>M; vector A(N,0); for(int &i:A)cin>>i; vector G(N,vector(0,0)); for(int i=0;i>U>>V; --U,--V; G[U].push_back(V); G[V].push_back(U); } vector vst(N,false); ll ans=1; for(int i=0;i bfs; bfs.push(i); vst[i]=1; while(bfs.size()){ int v=bfs.front(); bfs.pop(); for(int j:G[v]){ if(!vst[j]){ cnt+=1; now+=A[j]; bfs.push(j); vst[j]=1; } } } now%=mod; while(cnt>0){ cnt-=1; ans=ans*now%mod; } } cout<