MOD = 998244353 h, w, k = read_line.split.map(&.to_i) s = Array.new(h) { read_line.chars } dp = Array.new(h) { Array.new(w) { Array.new(k, 0i64) } } dp[0][0][0] = 1 h.times do |i| w.times do |j| next if s[i][j] == '#' k.times do |l| if i != h - 1 case s[i + 1][j] when 'o' if l < k - 1 dp[i + 1][j][l + 1] += dp[i][j][l] dp[i + 1][j][l + 1] %= MOD end when '.' dp[i + 1][j][l] += dp[i][j][l] dp[i + 1][j][l] %= MOD end end if j != w - 1 case s[i][j + 1] when 'o' if l < k - 1 dp[i][j + 1][l + 1] += dp[i][j][l] dp[i][j + 1][l + 1] %= MOD end when '.' dp[i][j + 1][l] += dp[i][j][l] dp[i][j + 1][l] %= MOD end end end end end puts dp[h - 1][w - 1].sum % MOD