#include #define rep(i,n) for(int i = 0; i < (n); i++) using namespace std; typedef long long ll; template struct Modint { using mint = Modint; long long v; Modint() : v(0) {} Modint(long long x) { x %= Modulus; if (x < 0) x += Modulus; v = x; } const long long& val() const { return v; } // 代入演算子 mint& operator+=(const mint rhs) { v += rhs.v; if (v >= Modulus) v -= Modulus; return *this; } mint& operator-=(const mint rhs) { if (v < rhs.v) v += Modulus; v -= rhs.v; return *this; } mint& operator*=(const mint rhs) { v = v * rhs.v % Modulus; return *this; } mint& operator/=(mint rhs) { return *this = *this * rhs.inv(); } // 累乗, 逆元 mint pow(long long n) const { mint x = *this, res = 1; while (n) { if (n & 1) res *= x; x *= x; n >>= 1; } return res; } mint inv() const { return pow(Modulus - 2); } // 算術演算子 mint operator+(const mint rhs) const { return mint(*this) += rhs; } mint operator-(const mint rhs) const { return mint(*this) -= rhs; } mint operator*(const mint rhs) const { return mint(*this) *= rhs; } mint operator/(const mint rhs) const { return mint(*this) /= rhs; } mint operator-() const { return mint() - *this; } // 単項 // 入出力ストリーム friend ostream& operator<<(ostream& os, const mint& p) { return os << p.v; } friend istream& operator>>(istream& is, mint& p) { long long t; is >> t; p = mint(t); return (is); } }; int main(){ cin.tie(0); ios::sync_with_stdio(0); int n; cin >> n; string s = ""; rep(i,n) { string t; cin >> t; s += t; } n *= 16; s += '.'; auto f = [&](char c) { if(c == '.') return 0; if(c == 'd') return 1; return 2; }; using mint = Modint<998244353>; vector> dp(n + 1, vector(3, 0)); dp[0][0] = 1; rep(i,n) { if(s[i] == '.') { dp[i + 1][f('.')] += dp[i][f('.')]; if(i % 2 == 1) dp[i + 1][f('.')] += dp[i][f('d')] + dp[i][f('k')]; if(s[i + 1] != 'd') { if(i % 2 == 0) dp[i + 1][f('d')] += dp[i][f('.')]; dp[i + 1][f('d')] += dp[i][f('d')] + dp[i][f('k')]; } if(s[i + 1] != 'k') { if(i % 2 == 0) dp[i + 1][f('k')] += dp[i][f('.')]; dp[i + 1][f('k')] += dp[i][f('d')] + dp[i][f('k')]; } } else { if(i % 2 == 0) dp[i + 1][f(s[i])] += dp[i][f('.')]; dp[i + 1][f(s[i])] += dp[i][f('d')] + dp[i][f('k')]; } } cout << dp[n][f('.')] + dp[n][f('d')] + dp[n][f('k')] << endl; }