#include #include #include #include using namespace std; using ll = long long; constexpr ll MOD = 998244353; int main(){ int h, w, k; cin >> h >> w >> k; vector s(h); for(auto &it: s) cin >> it; vector>> dp(h, vector>(w, vector(k+2, 0))); dp[0][0][k] = 1; for(int i = 0; i < h; i++){ for(int j = 0; j < w; j++){ if(s[i][j] == '#') continue; for(int l = 0; l <= k; l++){ if(i-1 >= 0 && s[i-1][j] != '#'){ dp[i][j][l] += dp[i-1][j][l+(s[i-1][j] == '.' ? 0 : 1)]; dp[i][j][l] %= MOD; } if(j-1 >= 0 && s[i][j-1] != '#'){ dp[i][j][l] += dp[i][j-1][l+(s[i][j-1] == '.' ? 0 : 1)]; dp[i][j][l] %= MOD; } } } } ll ans = 0; for(int i = 1; i <= k; i++){ ans += dp[h-1][w-1][i]; ans %= MOD; } cout << ans << endl; return 0; }