#include using namespace std; using ll = long long; const int MOD = 998244353; ll modpow(ll a, ll n) { ll r = 1; while (n) { if (n & 1) r = r * a % MOD; a = a * a % MOD; n >>= 1; } return r; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N, Q; cin >> N >> Q; string S; cin >> S; vector fact(N + 1), invfact(N + 1); fact[0] = 1; for (int i = 1; i <= N; ++i) { fact[i] = fact[i - 1] * i % MOD; } invfact[N] = modpow(fact[N], MOD - 2); for (int i = N; i >= 1; --i) { invfact[i - 1] = invfact[i] * i % MOD; } auto C = [&](int n, int k) -> ll { if (k < 0 || k > n) return 0; return fact[n] * invfact[k] % MOD * invfact[n - k] % MOD; }; auto cat = [&](int r) -> ll { return fact[2 * r] * invfact[r] % MOD * invfact[r + 1] % MOD; }; auto invcat = [&](int r) -> ll { return invfact[2 * r] * fact[r] % MOD * fact[r + 1] % MOD; }; vector T = {0}; int bad = 0; for (int i = 1; i < N; ++i) { if (S[i - 1] == S[i]) continue; if (i & 1) { ++bad; } else { T.push_back(i); } } ll P = 1; for (int i = 1; i < (int)T.size(); ++i) { P = P * cat((T[i] - T[i - 1]) / 2) % MOD; } auto insert_even = [&](int x) { int pos = lower_bound(T.begin(), T.end(), x) - T.begin(); int l = T[pos - 1]; if (pos < (int)T.size()) { int r = T[pos]; P = P * invcat((r - l) / 2) % MOD; P = P * cat((x - l) / 2) % MOD; P = P * cat((r - x) / 2) % MOD; } else { P = P * cat((x - l) / 2) % MOD; } T.insert(T.begin() + pos, x); // O(N) }; auto erase_even = [&](int x) { int pos = lower_bound(T.begin(), T.end(), x) - T.begin(); int l = T[pos - 1]; if (pos + 1 < (int)T.size()) { int r = T[pos + 1]; P = P * invcat((x - l) / 2) % MOD; P = P * invcat((r - x) / 2) % MOD; P = P * cat((r - l) / 2) % MOD; } else { P = P * invcat((x - l) / 2) % MOD; } T.erase(T.begin() + pos); // O(N) }; auto change_boundary = [&](int x) { if (x <= 0 || x >= N) return; bool diff = S[x - 1] != S[x]; if (x & 1) { bad += (diff ? -1 : 1); } else { if (diff) { erase_even(x); } else { insert_even(x); } } }; while (Q--) { int t, x; cin >> t >> x; if (t == 1) { change_boundary(x - 1); change_boundary(x); S[x - 1] = (S[x - 1] == 'Y' ? 'N' : 'Y'); } else { int K = x; if (bad) { cout << 0 << '\n'; continue; } int B = T.back(); int L = N - B; int q = K - B / 2; ll ans = 0; if (S.back() == 'Y') { if (0 <= q && q <= L / 2) { ans = P * ((C(L, q) - C(L, q - 1) + MOD) % MOD) % MOD; } } else { if ((L + 1) / 2 <= q && q <= L) { ans = P * ((C(L, q) - C(L, q + 1) + MOD) % MOD) % MOD; } } cout << ans << '\n'; } } }