#include #include using namespace std; using namespace atcoder; using ll = long long; using mint = modint998244353; int main(){ cin.tie(nullptr); ios_base::sync_with_stdio(false); int N, M, a, b, rem=0; string S; cin >> N >> M >> S; for (auto x : S) rem += (x == '?'); vector> E(N); for (int i=0; i> a >> b; a--; b--; E[a].push_back(b); E[b].push_back(a); } vector pw(N+1); pw[0] = 1; for (int i=1; i<=N; i++) pw[i] = pw[i-1] * 26; mint ans=0; for (int i=0; i= 1) ans += x*z*pw[rem-1]; // a ? if (rem >= 1) ans += z*y*pw[rem-1]; // ? i if (rem >= 2) ans += z*(z-1)*pw[rem-2]; // ? ? } else if (S[i] == '?'){ for (auto to : E[i]){ if (S[to] == 'a') x++; else if (S[to] == 'i') y++; else if (S[to] == '?') z++; } if (rem >= 1) ans += x*y*pw[rem-1]; // a i if (rem >= 2) ans += x*z*pw[rem-2]; // a ? if (rem >= 2) ans += z*y*pw[rem-2]; // ? i if (rem >= 3) ans += z*(z-1)*pw[rem-3]; // ? ? } } cout << ans.val() << endl; return 0; }