#include <bits/stdc++.h>
using namespace std;

#define rep(i, N) for (int i = 0; i < (N); i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back

using ll = long long;
using i_i = tuple<int, int>;

const int N = 10;
const int MOD = 998244353;

ll dp[N + 1][N + 1][2][2][2][2];

int main() {
    vector<vector<ll>> comb(N + 1, vector<ll>(N + 1));
    rep(x, N + 1) {
        comb[x][0] = 1;
        for (int y = 1; y <= x; y++)
            comb[x][y] = (comb[x - 1][y - 1] + comb[x - 1][y]) % MOD;
    }
    
    vector<vector<ll>> nibu(N + 1, vector<ll>(N + 1));
    rep(s, N * 2 + 1) rep(r, s + 1) {
        int c = s - r;
        if (r <= N && c <= N) {
            if (r == 0 || c == 0) nibu[r][c] = 1;
            else {
                for (int i = 1; i <= r; i++)
                    nibu[r][c] = (nibu[r][c] + nibu[c][r - i] * comb[r][i]) % MOD;
            }
        }
    }
    
    rep(r, N + 1) rep(c, N + 1) {
        if (r == 0 || c == 0) {
            rep(wr, 2) rep(wc, 2) rep(br, 2) rep(bc, 2) dp[r][c][wr][wc][br][bc] = 1;
        }
        else {
            rep(wr, 2) rep(wc, 2) rep(br, 2) rep(bc, 2) {
                if (wr && wc) dp[r][c][wr][wc][br][bc] += 1;
                if (br && bc) dp[r][c][wr][wc][br][bc] += 1;
                rep(iw, r) rep(ib, r) rep(jw, c) rep(jb, c) if (iw + ib + jw + jb > 0 && iw + ib <= r && jw + jb <= c) {
                    if (iw && jb) continue;
                    if (ib && jw) continue;
                    if (!wr && iw > 0) continue;
                    if (!wc && jw > 0) continue;
                    if (!br && ib > 0) continue;
                    if (!bc && jb > 0) continue;
                    int _wr = (jb > 0);
                    int _wc = (ib > 0);
                    int _br = (jw > 0);
                    int _bc = (iw > 0);
                    ll z = comb[r][iw] % MOD * comb[r - iw][ib] % MOD * comb[c][jw] % MOD * comb[c - jw][jb] % MOD;
                    dp[r][c][wr][wc][br][bc] = (dp[r][c][wr][wc][br][bc] + dp[r - iw - ib][c - jw - jb][_wr][_wc][_br][_bc] * z) % MOD;
                }
            }
        }
    }
    
    
    
    /*
    for (;;) {
        int r, c; cin >> r >> c;
        cout << dp[r][c][1][1][1][1] << endl;
    }
    */
    
    int H, W;
    cin >> H >> W;
    vector<vector<bool>> a(H, vector<bool>(W));
    rep(y, H) {
        string s; cin >> s;
        rep(x, W) a[y][x] = (s[x] == '#');
    }
    ll ans = dp[H][W][1][1][1][1];
    rep(S, 1<<H) rep(T, 1<<W) if (S && T) {
        bool ok = true;
        rep(y, H) if (S>>y & 1) {
            int z[2] = {0, 0};
            rep(x, W) if (T>>x & 1) z[a[y][x]] = 1;
            if (!z[0] || !z[1]) ok = false;
        }
        rep(x, W) if (T>>x & 1) {
            int z[2] = {0, 0};
            rep(y, H) if (S>>y & 1) z[a[y][x]] = 1;
            if (!z[0] || !z[1]) ok = false;
        }
        if (ok) {
            int R = H - __builtin_popcount(S);
            int C = W - __builtin_popcount(T);
            rep(wr, R + 1) rep(wc, C + 1) {
                int br = R - wr;
                int bc = C - wc;
                ll waf = (wr && bc) ? (nibu[wr][bc] + nibu[bc][wr]) : 1;
                ll rel = (wc && br) ? (nibu[wc][br] + nibu[br][wc]) : 1;
                ll z = comb[R][wr] * comb[C][wc] % MOD * waf % MOD * rel % MOD;
                ans = (ans + z) % MOD;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256