import io path = '/Users/ryohei/Desktop/input.txt' with open(path, 'r') as ff: ff = io.StringIO(ff.read()) def input() -> str: # overwrite the input function return ff.readline().strip() ################################################################################ MOD = 998244353 H, W, K = map(int, input().split()) S = [input() for _ in range(H)] # dp[i][j][k]: マス(i, j)に残り体力kでたどりつく組み合わせの数 dp = [[[0] * (K + 1) for _ in range(W)] for _ in range(H)] dp[0][0][K] = 1 for h in range(H): for w in range(W): if w + 1 < W: if S[h][w+1] == '.': for k in range(1, K+1): dp[h][w+1][k] += dp[h][w][k] dp[h][w+1][k] %= MOD elif S[h][w+1] == 'o': for k in range(2, K+1): dp[h][w+1][k-1] += dp[h][w][k] dp[h][w+1][k-1] %= MOD if h + 1 < H: if S[h+1][w] == '.': for k in range(1, K+1): dp[h+1][w][k] += dp[h][w][k] dp[h+1][w][k] %= MOD elif S[h+1][w] == 'o': for k in range(2, K+1): dp[h+1][w][k-1] += dp[h][w][k] dp[h+1][w][k-1] %= MOD ans = sum(dp[-1][-1]) print(ans % MOD)