#include using namespace std::literals::string_literals; using i64 = std::int_fast64_t; using std::cerr; using std::cin; using std::cout; using std::endl; #if defined(DONLINE_JUDGE) #define NDEBUG #elif defined(ONLINE_JUDGE) #define NDEBUG #endif template std::vector make_v(size_t a) { return std::vector(a); } template auto make_v(size_t a, Ts... ts) { return std::vector(ts...))>(a, make_v(ts...)); } int main() { int h, w, k; scanf("%d%d%d", &h, &w, &k); std::vector s(h); for (auto& v : s) std::cin >> v; const int MOD = 998244353; auto dp = make_v(h, w, k + 1); for (auto& x : dp) for (auto& y : x) for (auto& z : y) z = 0; dp[0][0][0] = 1; for (int y = 0; y < h; ++y) { for (int x = 0; x < w; ++x) { for (int i = 0; i < k; ++i) { if (y + 1 < h and s[y + 1][x] != '#') { const int ni = i + (s[y + 1][x] == 'o'); dp[y + 1][x][ni] = (dp[y + 1][x][ni] + dp[y][x][i]) % MOD; } if (x + 1 < w and s[y][x + 1] != '#') { const int ni = i + (s[y][x + 1] == 'o'); dp[y][x + 1][ni] = (dp[y][x + 1][ni] + dp[y][x][i]) % MOD; } } } } int ans = 0; for (int i = 0; i < k; ++i) ans = (ans + dp[h - 1][w - 1][i]) % MOD; printf("%d\n", ans); return 0; }