#include #include #include using i32 = std::int32_t; using u32 = std::uint32_t; using i64 = std::int64_t; using u64 = std::uint64_t; using i128 = __int128_t; using u128 = __uint128_t; using isize = std::ptrdiff_t; using usize = std::size_t; class rep { struct Iter { usize itr; constexpr Iter(const usize pos) noexcept : itr(pos) {} constexpr void operator++() noexcept { ++itr; } constexpr bool operator!=(const Iter& other) const noexcept { return itr != other.itr; } constexpr usize operator*() const noexcept { return itr; } }; const Iter first, last; public: explicit constexpr rep(const usize first, const usize last) noexcept : first(first), last(std::max(first, last)) {} constexpr Iter begin() const noexcept { return first; } constexpr Iter end() const noexcept { return last; } }; class revrep { struct Iter { usize itr; constexpr Iter(const usize pos) noexcept : itr(pos) {} constexpr void operator++() noexcept { --itr; } constexpr bool operator!=(const Iter& other) const noexcept { return itr != other.itr; } constexpr usize operator*() const noexcept { return itr; } }; const Iter first, last; public: explicit constexpr revrep(const usize first, const usize last) noexcept : first(last - 1), last(std::min(first, last) - 1) {} constexpr Iter begin() const noexcept { return first; } constexpr Iter end() const noexcept { return last; } }; constexpr u64 ceil_log2(const u64 x) { u64 e = 0; while (((u64)1 << e) < x) ++e; return e; } template class AutoRealloc { using R = typename decltype(std::declval()((usize)0))::value_type; F func; mutable std::vector data; public: template explicit AutoRealloc(G&& g) : func(std::forward(g)), data() {} void reserve(const usize size) const { if (data.size() < size) data = func(((usize)1 << ceil_log2(size))); } R operator[](const usize i) const { reserve(i + 1); return data[i]; } }; template explicit AutoRealloc(G&&) -> AutoRealloc>; template struct ModintUtil { static inline const auto fact = AutoRealloc([](const usize n) { std::vector ret(n); ret[0] = M(1); for (const usize i : rep(1, n)) { ret[i] = ret[i - 1] * M(i); } return ret; }); static inline const auto inv = AutoRealloc([](const usize n) { std::vector ret(n); if (n == 1) return ret; ret[1] = M(1); for (const usize i : rep(2, n)) { ret[i] = -M(M::mod() / i) * ret[M::mod() % i]; } return ret; }); static inline const auto inv_fact = AutoRealloc([](const usize n) { std::vector ret(n); ret[0] = M(1); for (const usize i : rep(1, n)) { ret[i] = ret[i - 1] * inv[i]; } return ret; }); static M binom(const usize n, const usize k) { assert(k <= n); return fact[n] * inv_fact[n - k] * inv_fact[k]; } static M factpow(const usize n, const usize k) { assert(k <= n); return fact[n] * inv_fact[n - k]; } static M homo(const usize n, const usize k) { if (n == 0 and k == 0) return M(1); return binom(n + k - 1, k); } }; template using Vec = std::vector; using Fp = atcoder::modint998244353; using Util = ModintUtil; void F_main() { usize N; std::cin >> N; Vec A(N), B(N); for (const auto i : rep(0, N)) { char c; std::cin >> c; (c == 'i' ? A[N - i - 1] : B[i]) = Fp(1); } auto C = atcoder::convolution(A, B); C.erase(C.begin(), C.begin() + N); Vec D(N - 1); for (const auto i : rep(0, N - 1)) { C[i] *= Util::fact[i]; D[i] = Util::inv_fact[N - i - 2]; } const auto E = atcoder::convolution(C, D); u32 ans = 0; for (const auto i : rep(N - 2, 2 * N - 3)) { ans ^= (E[i] * Util::inv_fact[i - (N - 2)]).val(); } std::cout << ans << '\n'; } int main() { std::ios_base::sync_with_stdio(false); std::cin.tie(nullptr); F_main(); return 0; }