N = int(input()) S = '.'+''.join([input() for _ in range(N)])+'.' MOD = 998244353 ans = [0]*3 ans[0] = 1 T = '.dk' U = [T.index(s) for s in S] dp = [[0]*3 for _ in range(16*N+1)] dp[0] = [1, 0, 0] for i in range(1, 16*N+1): s = U[i] if s: dp[i][s] = sum(dp[i-1]) % MOD else: if i % 2: if U[i+1] == 0: dp[i][0] = dp[i-1][0] if U[i+1] != 1: dp[i][1] = sum(dp[i-1]) % MOD if U[i+1] != 2: dp[i][2] = sum(dp[i-1]) % MOD else: dp[i][0] = sum(dp[i-1]) % MOD if U[i+1] != 1: dp[i][1] = (sum(dp[i-1])-dp[i-1][0]) % MOD if U[i+1] != 2: dp[i][2] = (sum(dp[i-1])-dp[i-1][0]) % MOD print(sum(dp[-1]) % MOD)