// 想定解 ver #include #include #include #include #include #define FOR(i,k,n) for(int i = (k);i < (n);++i) #define REP(i,n) FOR(i,0,n) #define ALL(x) begin(x),end(x) using namespace std; using vecint = vector; using ll = int64_t; using vecll = vector; const double pi = acos(-1.0); constexpr ll MOD = 998244353; constexpr ll MAX_F = 600000; struct Mod { int n; Mod () : n(0) {;} Mod (int m) : n(m) { if (n >= MOD) n %= MOD; else if (n < 0) n = (n % MOD + MOD) % MOD; } operator int() { return n; } }; bool operator==(Mod a, Mod b) { return a.n == b.n; } Mod operator+=(Mod &a, Mod b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; } Mod operator-=(Mod &a, Mod b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; } Mod operator*=(Mod &a, Mod b) { a.n = ((long long)a.n * b.n) % MOD; return a; } Mod operator+(Mod a, Mod b) { return a += b; } Mod operator-(Mod a, Mod b) { return a -= b; } Mod operator*(Mod a, Mod b) { return a *= b; } Mod operator^(Mod a, int n) { if (n == 0) return Mod(1); Mod res = (a * a) ^ (n / 2); if (n % 2) res = res * a; return res; } ll inv(ll a, ll p) { return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p); } Mod operator/(Mod a, Mod b) { return a * Mod(inv(b, MOD)); } using P = Mod; vector

NTT(P omega, const vector

&a) { const int n = a.size(); vector

ret = a; for (int m = n; m >= 2; m >>= 1, omega *= omega) { P rho = 1; REP(i,m/2) { for (int j = i; j < n; j += m) { int k = j + m / 2; P x = ret[j] - ret[k]; ret[j] += ret[k]; ret[k] = rho * x; } rho *= omega; } } for (int i = 0, j = 1; j < n - 1; j++) { for (int k = n >> 1; k > (i ^= k); k >>= 1) {;} if (j < i) swap(ret[i], ret[j]); } return ret; } vector convolution(const vector &lhs, const vector &rhs) { int n = 1, a = lhs.size(), b = rhs.size(); while (n < max(a, b) * 2) n <<= 1; vector

temp1(n), temp2(n); REP(i,n/2) { if (i < a) temp1[i] = P(lhs[i]); if (i < b) temp2[i] = P(rhs[i]); } P root = 3; int index = (MOD - 1) / n; P omega = root ^ index; temp1 = NTT(omega, temp1); temp2 = NTT(omega, temp2); REP(i,n) temp1[i] *= temp2[i]; temp1 = NTT(P(1)/omega, temp1); vector ret(n); REP(i,n) ret[i] = temp1[i] / P(n); return ret; } int main() { vecll fact(MAX_F+1), finv(MAX_F+1); fact[0] = 1; REP(i,MAX_F) { fact[i+1] = fact[i] * (i+1) % MOD; } finv[MAX_F] = inv(fact[MAX_F], MOD); REP(ri,MAX_F) { int i = MAX_F - ri; finv[i-1] = finv[i] * i % MOD; } ll n; cin>>n; string s; cin>>s; vecll left_i(n, 0), right_n(n, 0); REP(i,n) { if (s[i] == 'i') { left_i[i] = 1; } else { right_n[n-1-i] = 1; } } auto poly = convolution(left_i, right_n); vecll a(n+1); REP(i,n-1) { a[i] = poly[n-2-i] * fact[i] % MOD; } vecll b(n+1); REP(i,n+1) { b[i] = finv[n-i]; } vecll poly2 = convolution(a, b); ll ans = 0; REP(i,n-1) { ll tmp = poly2[i+n] * finv[i] % MOD; ans ^= tmp; } cout<