import sys # sys.setrecursionlimit(200005) int1 = lambda x: int(x)-1 p2D = lambda x: print(*x, sep="\n") def II(): return int(sys.stdin.readline()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def LI1(): return list(map(int1, sys.stdin.readline().split())) def LLI1(rows_number): return [LI1() for _ in range(rows_number)] def SI(): return sys.stdin.readline().rstrip() # dij = [(0, 1), (-1, 0), (0, -1), (1, 0)] # dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)] inf = 18446744073709551615 # inf = 4294967295 # md = 10**9+7 md = 998244353 n = II() aa = [] for _ in range(n): aa += [".dk".find(c) for c in SI()] n *= 16 # print(aa) dp = [0]*3 a = aa[0] if a == 0: dp[0] = 1 if n > 1 and aa[1] > 0: dp[3-aa[1]] = 1 else: dp[1] = 1 dp[2] = 1 else: dp[a] = 1 for i, a in enumerate(aa[1:], 1): ndp = [0]*3 for j in range(3): if dp[j] == 0: continue if a == 0: for nj in range(3): if i & 1 == 0 and j > 0 and nj == 0: continue if i & 1 and j == 0 and nj > 0: continue if i+1 < n and a == 0 and aa[i+1] > 0 and nj == aa[i+1]: continue ndp[nj] += dp[j] if i & 1 and j == 0: continue if a == 1: ndp[a] += dp[j] if a == 2: ndp[a] += dp[j] for j in range(3): ndp[j] %= md dp = ndp # print(i, a, dp) print(sum(dp)%md)