#include using namespace std; #define rep(i, n) for (int i = 0; i < (n); ++i) using ll = long long; using ull = unsigned long long; #include using mint = atcoder::modint998244353; int main() { cin.tie(nullptr)->sync_with_stdio(false); int h, w, k; cin >> h >> w >> k; vector Grid(h, vector(w)); rep(i, h) rep(j, w) cin >> Grid[i][j]; queue> q; vector dp(h, vector(w, vector(k, 0))); vector added(h, vector(w, vector(k, false))); dp[0][0][0] = 1; q.push({ 0, 0, 0 }); while (!q.empty()) { auto [x, y, hp] = q.front(); q.pop(); if (x + 1 < h) { if (Grid[x + 1][y] != '#') { int nhp = hp + (Grid[x + 1][y] == 'o'); if (nhp < k) { dp[x + 1][y][nhp] += dp[x][y][hp]; if (!added[x + 1][y][nhp]) q.push({ x + 1, y, nhp }); added[x + 1][y][nhp] = true; } } } if (y + 1 < w) { if (Grid[x][y + 1] != '#') { int nhp = hp + (Grid[x][y + 1] == 'o'); if (nhp < k) { dp[x][y + 1][nhp] += dp[x][y][hp]; if (!added[x][y + 1][nhp]) q.push({ x, y + 1, nhp }); added[x][y + 1][nhp] = true; } } } } mint ans = 0; rep(i, k) ans += dp[h - 1][w - 1][i]; cout << ans.val() << '\n'; return 0; }