#include using namespace std; #include using namespace atcoder; using mint = modint998244353; void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); } int main() { fast_io(); 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, 0))); dp[0][0][0] = 1; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { for (int l = 0; l < k; l++) { if (j < w - 1 && s[i][j + 1] != '#') { if (s[i][j + 1] == '.') { dp[i][j + 1][l] += dp[i][j][l]; } else if (l < k - 1) { dp[i][j + 1][l + 1] += dp[i][j][l]; } } if (i < h - 1 && s[i + 1][j] != '#') { if (s[i + 1][j] == '.') { dp[i + 1][j][l] += dp[i][j][l]; } else if (l < k - 1) { dp[i + 1][j][l + 1] += dp[i][j][l]; } } } } } mint ans = 0; for (int i = 0; i < k; i++) { ans += dp[h - 1][w - 1][i]; } cout << ans.val() << endl; }