def list3d(a, b, c, val=0): return [[[val] * c for _ in range(b)] for _ in range(a)] MOD = 998244353 H, W, K = map(int, input().split()) S = [input() for _ in range(H)] dp = list3d(H+1, W+1, H+W+1) dp[0][0][0] = 1 for i in range(H): for j in range(W): if S[i][j] == '#': continue for k in range(K): for dr, dc in [(1, 0), (0, 1)]: r = i + dr c = j + dc if not (0 <= r < H and 0 <= c < W): continue if S[r][c] == '#': continue d = 1 if S[r][c] == 'o' else 0 dp[r][c][k+d] += dp[i][j][k] dp[r][c][k+d] %= MOD ans = 0 for k in range(K): ans += dp[H-1][W-1][k] ans %= MOD print(ans)