// #pragma GCC target("avx") // #pragma GCC optimize("O3") // #pragma GCC optimize("unroll-loops") #include using namespace std; #define rep(i,n) for(int i = 0; i < (int)n; i++) #define FOR(n) for(int i = 0; i < (int)n; i++) #define repi(i,a,b) for(int i = (int)a; i < (int)b; i++) #define all(x) x.begin(),x.end() //#define mp make_pair #define vi vector #define vvi vector #define vvvi vector #define vvvvi vector #define pii pair #define vpii vector> template void chmax(T &a, const T &b) {a = (a > b? a : b);} template void chmin(T &a, const T &b) {a = (a < b? a : b);} using ll = long long; using ld = long double; using ull = unsigned long long; const ll INF = numeric_limits::max() / 2; const ld pi = 3.1415926535897932384626433832795028; const ll mod = 998244353; int dx[] = {1, 0, -1, 0, -1, -1, 1, 1}; int dy[] = {0, 1, 0, -1, -1, 1, -1, 1}; #define int long long template struct Modular_Int { long long x; Modular_Int() = default; Modular_Int(long long x_) : x(x_ >= 0? x_%MOD : (MOD-(-x_)%MOD)%MOD) {} long long val() const { return (x%MOD+MOD)%MOD; } long long get_mod() const { return MOD; } Modular_Int& operator^=(long long d) { Modular_Int ret(1); long long nx = x; while(d) { if(d&1) ret *= nx; (nx *= nx) %= MOD; d >>= 1; } *this = ret; return *this; } Modular_Int operator^(long long d) const {return Modular_Int(*this) ^= d;} Modular_Int pow(long long d) const {return Modular_Int(*this) ^= d;} //use this basically Modular_Int inv() const { return Modular_Int(*this) ^ (MOD-2); } //only if the module number is not prime //Don't use. This is broken. // Modular_Int inv() const { // long long a = (x%MOD+MOD)%MOD, b = MOD, u = 1, v = 0; // while(b) { // long long t = a/b; // a -= t*b, swap(a, b); // u -= t*v, swap(u, v); // } // return Modular_Int(u); // } Modular_Int& operator+=(const Modular_Int other) { if((x += other.x) >= MOD) x -= MOD; return *this; } Modular_Int& operator-=(const Modular_Int other) { if((x -= other.x) < 0) x += MOD; return *this; } Modular_Int& operator*=(const Modular_Int other) { long long z = x; z *= other.x; z %= MOD; x = z; if(x < 0) x += MOD; return *this; } Modular_Int& operator/=(const Modular_Int other) { return *this = *this * other.inv(); } Modular_Int& operator++() { x++; if (x == MOD) x = 0; return *this; } Modular_Int& operator--() { if (x == 0) x = MOD; x--; return *this; } Modular_Int operator+(const Modular_Int other) const {return Modular_Int(*this) += other;} Modular_Int operator-(const Modular_Int other) const {return Modular_Int(*this) -= other;} Modular_Int operator*(const Modular_Int other) const {return Modular_Int(*this) *= other;} Modular_Int operator/(const Modular_Int other) const {return Modular_Int(*this) /= other;} Modular_Int& operator+=(const long long other) {Modular_Int other_(other); *this += other_; return *this;} Modular_Int& operator-=(const long long other) {Modular_Int other_(other); *this -= other_; return *this;} Modular_Int& operator*=(const long long other) {Modular_Int other_(other); *this *= other_; return *this;} Modular_Int& operator/=(const long long other) {Modular_Int other_(other); *this /= other_; return *this;} Modular_Int operator+(const long long other) const {return Modular_Int(*this) += other;} Modular_Int operator-(const long long other) const {return Modular_Int(*this) -= other;} Modular_Int operator*(const long long other) const {return Modular_Int(*this) *= other;} Modular_Int operator/(const long long other) const {return Modular_Int(*this) /= other;} bool operator==(const Modular_Int other) const {return (*this).val() == other.val();} bool operator!=(const Modular_Int other) const {return (*this).val() != other.val();} bool operator==(const long long other) const {return (*this).val() == other;} bool operator!=(const long long other) const {return (*this).val() != other;} Modular_Int operator-() const {return Modular_Int(0LL)-Modular_Int(*this);} // friend constexpr istream& operator>>(istream& is, mint& x) noexcept { // long long X; // is >> X; // x = X; // return is; // } // friend constexpr ostream& operator<<(ostream& os, mint& x) { // os << x.val(); // return os; // } }; // const long long MOD_VAL = 1e9+7; const long long MOD_VAL = 998244353; using mint = Modular_Int; void solve() { int h, w, k; cin >> h >> w >> k; vector s(h); FOR(h) cin >> s[i]; vector>> dp(h, vector>(w, vector(k+1))); dp[0][0][k] = 1; rep(i, h) rep(j, w) if(s[i][j] != '#') { if(i != 0) { if(s[i][j] == '.') { rep(health, k+1) dp[i][j][health] += dp[i-1][j][health]; }else { rep(health, k) dp[i][j][health] += dp[i-1][j][health+1]; } } if(j != 0) { if(s[i][j] == '.') { rep(health, k+1) dp[i][j][health] += dp[i][j-1][health]; }else { rep(health, k) dp[i][j][health] += dp[i][j-1][health+1]; } } } mint ans = 0; repi(health, 1, k+1) ans += dp[h-1][w-1][health]; cout << ans.val() << endl; } signed main() { cin.tie(nullptr); ios::sync_with_stdio(false); solve(); return 0; }