import sys input = sys.stdin.readline mod = 998244353 n = int(input()) s = ''.join([input().rstrip() for i in range(n)])+'.' notes = ".dk"; dp = [1,0,0] for i in range(16*n): for j in range(3): dp[j] %= mod nxt = [0]*3 if s[i] == '.': nxt[0] += dp[0] if i % 2 == 1: nxt[0] += dp[1] + dp[2] if s[i + 1] != 'd': if i % 2 == 0: nxt[1] += dp[0] nxt[1] += dp[1] + dp[2] if s[i + 1] != 'k': if i % 2 == 0: nxt[2] += dp[0] nxt[2] += dp[1] + dp[2] else: if i % 2 == 0: nxt[notes.index(s[i])] += dp[0] nxt[notes.index(s[i])] += dp[1] + dp[2] dp = nxt print(sum(dp) % mod)