#include #include using mint = atcoder::modint998244353; using namespace std; int dx[2] = {1, 0}; int dy[2] = {0, 1}; int main() { int H, W, K; cin >> H >> W >> K; vector S(H); for (int i = 0; i < H; i++){ cin >> S[i]; } vector>> dp(H, vector>(W, vector(K + 1))); dp[0][0][K] = 1; for (int i = 0; i < H; i++){ for (int j = 0; j < H; j++){ for (int k = 0; k <= K; k++){ for (int l = 0; l < 2; l++){ int px = i + dx[l], py = j + dy[l]; if (0 <= px and px < H and 0 <= py and py < W and S[px][py] != '#'){ if (S[px][py] == '.'){ dp[px][py][k] += dp[i][j][k]; } else { if (k > 1){ dp[px][py][k - 1] += dp[i][j][k]; } } } } } } } mint ans = 0; for (int i = 1; i <= K; i++){ ans += dp[H - 1][W - 1][i]; } cout << ans.val() << '\n'; }