#include using namespace std; using ll = long long; template struct ModInt { int x; ModInt() : x(0) {} ModInt(ll v) : x(v % MOD) { if (x < 0) x += MOD; } ModInt operator+(const ModInt &o) const { int r = x + o.x; return r >= MOD ? r - MOD : r; } ModInt operator-(const ModInt &o) const { int r = x - o.x; return r < 0 ? r + MOD : r; } ModInt operator*(const ModInt &o) const { return (ll)x * o.x % MOD; } ModInt operator-() const { return x ? MOD - x : 0; } ModInt& operator+=(const ModInt &o) { if ((x += o.x) >= MOD) x -= MOD; return *this; } ModInt& operator-=(const ModInt &o) { if ((x -= o.x) < 0) x += MOD; return *this; } ModInt& operator*=(const ModInt &o) { x = (ll)x * o.x % MOD; return *this; } ModInt pow(ll e) const { ModInt res(1), b(*this); for (; e; e >>= 1, b *= b) { if (e & 1) res *= b; } return res; } ModInt inv() const { return pow(MOD - 2); } ModInt operator/(const ModInt &o) const { return *this * o.inv(); } ModInt& operator/=(const ModInt &o) { return *this *= o.inv(); } bool operator==(const ModInt &o) const { return x == o.x; } bool operator!=(const ModInt &o) const { return x != o.x; } friend ostream& operator<<(ostream &os, const ModInt &m) { return os << m.x; } }; using mint = ModInt<998244353>; int main() { cin.tie(nullptr); ios_base::sync_with_stdio(false); int h, w; cin >> h >> w; vector s(h); for (int i = 0; i < h; i++) cin >> s[i]; vector> dp1(h, vector(w, 0)), dp2 = dp1; dp1[0][1] = 1; dp2[1][0] = 1; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { if (s[i][j] == '#') continue; if (i > 0) { dp1[i][j] += dp1[i - 1][j]; dp2[i][j] += dp2[i - 1][j]; } if (j > 0) { dp1[i][j] += dp1[i][j - 1]; dp2[i][j] += dp2[i][j - 1]; } } } mint ans = dp1[h - 2][w - 1] * dp2[h - 1][w - 2] - dp1[h - 1][w - 2] * dp2[h - 2][w - 1]; cout << ans << "\n"; return 0; }