import sys readline = sys.stdin.readline N = int(readline()) mod = 998244353 S = [] for i in range(N): s = readline().rstrip() S.extend(list(s)) N *= 16 dp0 = [0] * N dp1 = [0] * N dp2 = [0] * N if S[0] == "d": dp1[0] = 1 elif S[0] == "k": dp2[0] = 1 else: dp0[0] = 1 dp1[0] = 1 dp2[0] = 1 for i in range(1, N): if S[i] == ".": if i % 2: dp0[i] += dp0[i - 1] + dp1[i - 1] + dp2[i - 1] dp1[i] += dp2[i - 1] + dp1[i - 1] dp2[i] += dp1[i - 1] + dp2[i - 1] else: dp0[i] += dp0[i - 1] dp1[i] += dp2[i - 1] + dp0[i - 1] + dp1[i - 1] dp2[i] += dp1[i - 1] + dp0[i - 1] + dp2[i - 1] elif S[i] == "d": if i % 2 == 0: dp1[i] += dp0[i - 1] + dp1[i - 1] + dp2[i - 1] if S[i - 1] == ".": dp1[i] -= dp1[i - 1] else: dp1[i] += dp1[i - 1] + dp2[i - 1] if S[i - 1] == ".": dp1[i] -= dp1[i - 1] else: if i % 2 == 0: dp2[i] += dp0[i - 1] + dp1[i - 1] + dp2[i - 1] if S[i - 1] == ".": dp2[i] -= dp2[i - 1] else: dp2[i] += dp1[i - 1] + dp2[i - 1] if S[i - 1] == ".": dp2[i] -= dp2[i - 1] dp0[i] %= mod dp1[i] %= mod dp2[i] %= mod print( (dp0[-1] + dp1[-1] + dp2[-1] ) % mod )