#include #include using namespace std; using namespace atcoder; using ld = long double; using ll = long long; const ld pi = acos(-1.0); const ld tau = 2*pi; const ll MOD = 998244353; using mint = modint998244353; istream &operator>>(istream &is, modint998244353 &a) { long long v; is >> v; a = v; return is; } ostream &operator<<(ostream &os, const modint998244353 &a) { return os << a.val(); } istream &operator>>(istream &is, modint1000000007 &a) { long long v; is >> v; a = v; return is; } ostream &operator<<(ostream &os, const modint1000000007 &a) { return os << a.val(); } template istream &operator>>(istream &is, static_modint &a) { long long v; is >> v; a = v; return is; } template istream &operator>>(istream &is, dynamic_modint &a) { long long v; is >> v; a = v; return is; } template ostream &operator<<(ostream &os, const static_modint &a) { return os << a.val(); } template ostream &operator<<(ostream &os, const dynamic_modint &a) { return os << a.val(); } template istream &operator>>(istream &is, vector &v) { for (auto &e : v) is >> e; return is; } template ostream &operator<<(ostream &os, const vector &v) { for (auto &e : v) os << e << ' '; return os; } #define Rep(parameter, start, end) for(int parameter = start; parameter < (ll)(end); parameter++) #define rep(parameter, end) Rep(parameter, 0, end) #define rRep(parameter, start, end) for(int parameter = (ll)(end)-1; parameter >= start; parameter--) #define rrep(parameter, end) rRep(parameter, 0, end) int main() { int H, W, K; cin >> H >> W >> K; vector field(H); rep(i,H) cin >> field[i]; vector>> dp(110, vector>(110, vector(210, 0))); dp[0][0][K-1] = 1; rep(i,H){ rep(j,W){ if(i==0 && j==0) continue; rrep(k,K){ // cout << i << ' ' << j << ' ' << k << endl; if(field[i][j] == '#'){ dp[i][j][k] = 0; } if(field[i][j] == '.'){ dp[i][j][k] = (i==0?0:dp[i-1][j][k]) + (j==0?0:dp[i][j-1][k]); } if(field[i][j] == 'o'){ dp[i][j][k] = (k==K-1?0:(i==0?0:dp[i-1][j][k+1]) + (j==0?0:dp[i][j-1][k+1])); } } } } // rep(i,H){ // rep(j,W){ // mint ans = 0; // rep(k,K) ans += dp[i][j][k]; // cout << ans << (j!=W-1?' ':'\n'); // } // } // rep(i,H){ // rep(k,K){ // rep(j,W){ // printf("%2d", dp[i][j][k].val()); // if(j == W-1 && k == K-1) cout << endl; // else if(j == W-1) cout << " : "; // else cout << ' '; // } // } // } mint ans = 0; rep(i,K) ans += dp[H-1][W-1][i]; cout << ans << endl; } /* if field[i][j] == '#': dp[i][j][k] = 0 if field[i][j] == '.': dp[i][j][k] = dp[i-1][j][k] + dp[i][j-1][k] if field[i][j] == 'o': dp[i][j][k] = dp[i-1][j][k-1] + dp[i][j-1][k-1] */