#include #include using mint = atcoder::modint998244353; int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int N, M; std::string S; std::cin >> N >> M >> S; std::vector> G(N); for (int i = 0; i < M; i++) { int a, b; std::cin >> a >> b; a--, b--; G[a].push_back(b); G[b].push_back(a); } int q = 0; for (int i = 0; i < N; i++) { q += (S[i] == '?'); } std::vector pow(q + 1, 1); for (int i = 0; i < q; i++) { pow[i + 1] = 26 * pow[i]; } mint ans = 0; for (int i = 0; i < N; i++) { if (S[i] == 'o') { int cnt_a = 0, cnt_i = 0, cnt_q = 0; for (auto v : G[i]) { if (S[v] == 'a') { cnt_a++; } else if (S[v] == 'i') { cnt_i++; } else if (S[v] == '?') { cnt_q++; } } ans += cnt_a * cnt_i * pow[q]; if (q > 0) { ans += cnt_a * cnt_q * pow[q - 1]; ans += cnt_i * cnt_q * pow[q - 1]; } if (q > 1) { ans += cnt_q * (cnt_q - 1) * pow[q - 2]; } } else if (S[i] == '?') { int cnt_a = 0, cnt_i = 0, cnt_q = 0; for (auto v : G[i]) { if (S[v] == 'a') { cnt_a++; } else if (S[v] == 'i') { cnt_i++; } else if (S[v] == '?') { cnt_q++; } } ans += cnt_a * cnt_i * pow[q - 1]; if (q > 1) { ans += cnt_a * cnt_q * pow[q - 2]; ans += cnt_i * cnt_q * pow[q - 2]; } if (q > 2) { ans += cnt_q * (cnt_q - 1) * pow[q - 3]; } } } std::cout << ans.val() << '\n'; }