MOD = 998244353i64 n = read_line.to_i s = Array.new(n) { read_line.chars }.flatten dp = [[0i64, 0i64], [0i64, 0i64]] dp2 = [[1i64, 0i64], [0i64, 0i64]] (n * 16).times do |i| dp, dp2 = dp2, dp dp2.each { |a| a.fill(0i64) } if s[i] != '.' dp2[1][1] = (dp[0][1] + dp[1][1]) % MOD if i % 2 == 0 dp2[0][1] = (dp[0][0] + dp[1][0]) % MOD end else mul = (i != 16 * n - 1 && s[i + 1] != '.') ? 1 : 2 dp2[0][0] = (dp[0][0] + dp[1][0]) % MOD if i % 2 == 1 dp2[1][0] = (dp[0][1] + dp[1][1]) % MOD end dp2[1][1] = (dp[0][1] + dp[1][1]) * mul % MOD if i % 2 == 0 dp2[0][1] = (dp[0][0] + dp[1][0]) * mul % MOD end end end puts dp2.flatten.sum % MOD