#include using namespace std; typedef long long ll; const ll MOD = 998244353; ll dp[200005][3]; int main() { int n; cin >> n; string s = "."; for(int i = 0; i < n; i++){ string t; cin >> t; s += t; } n = n * 16 + 1; dp[0][2] = 1; for(int i = 1; i < n; i++){ if(s[i] == 'd'){ if(s[i - 1] == '.'){ if(i % 2) dp[i][0] = (dp[i - 1][1] + dp[i - 1][2]) % MOD; else dp[i][0] = dp[i - 1][1]; } else dp[i][0] = (dp[i - 1][0] + dp[i - 1][1] + dp[i - 1][2]) % MOD; } if(s[i] == 'k'){ if(s[i - 1] == '.'){ if(i % 2) dp[i][1] = (dp[i - 1][0] + dp[i - 1][2]) % MOD; else dp[i][1] = dp[i - 1][0]; } else dp[i][0] = (dp[i - 1][0] + dp[i - 1][1] + dp[i - 1][2]) % MOD; } if(s[i] == '.'){ if(i % 2){ dp[i][0] = (dp[i - 1][0] + dp[i - 1][1] + dp[i - 1][2]) % MOD; dp[i][1] = (dp[i - 1][0] + dp[i - 1][1] + dp[i - 1][2]) % MOD; dp[i][2] = dp[i - 1][2]; } else{ dp[i][0] = (dp[i - 1][0] + dp[i - 1][1]) % MOD; dp[i][1] = (dp[i - 1][0] + dp[i - 1][1]) % MOD; dp[i][2] = (dp[i - 1][0] + dp[i - 1][1] + dp[i - 1][2]) % MOD; } } } cout << (dp[n - 1][0] + dp[n - 1][1] + dp[n - 1][2]) % MOD << endl; }