#include <bits/stdc++.h>

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

const int maxn = 10;
const i64 P = 998244353;
string s[maxn];

i64 mult[maxn + 1][maxn + 1];
i64 dp[maxn + 1][maxn + 1][16];
i64 cnk[maxn + 1][maxn + 1];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "rt", stdin);
#endif

    cnk[0][0] = 1;
    forn(i, maxn) forn(j, i + 1) forn(z, 2) cnk[i + 1][j + z] += cnk[i][j];

    int n, m;
    cin >> n >> m;
    forn(i, n) cin >> s[i];

    forn(h, n + 1) forn(w, m + 1) {
        if (min(w, h) == 0 && max(w, h) != 0) continue;
        forn(i, n + 1) forn(j, m + 1) forn(mask, 16) dp[i][j][mask] = 0;
        dp[n][m][0] = 1;
        i64 res = 0;
        ford(i, n + 1) ford(j, m + 1) forn(mask, 16) {
            if (i < h) continue;
            if (j < w) continue;
            if (dp[i][j][mask] == 0) continue;
//            if (h == 0) cerr << i << ' ' << j << ' ' << mask << ' ' << dp[i][j][mask] << '\n';
            if (min(i, j) == 0) {
                res += dp[i][j][mask];
                res %= P;
                continue;
            }
            forn(br, i - h + 1) forn(wr, i - h - br + 1) forn(bc, j - w + 1) forn(wc, j - w - bc + 1) {
                if ((mask & 1) && br > 0) continue;
                if ((mask & 2) && wr > 0) continue;
                if ((mask & 4) && bc > 0) continue;
                if ((mask & 8) && wc > 0) continue;
                if (br > 0 && wc > 0) continue;
                if (wr > 0 && bc > 0) continue;
                if (br + wr + bc + wc == 0) continue;
                if (wr == i && wc < j) continue;
                if (br == i && bc < j) continue;
                if (wc == j && wr < i) continue;
                if (bc == j && br < i) continue;

                i64 coef = cnk[i - h][br + wr] * cnk[br + wr][br] % P * cnk[j - w][bc + wc] % P * cnk[bc + wc][bc] % P;
                int nmask = 0;
                if (bc + wc == 0) nmask |= 3;
                if (br + wr == 0) nmask |= 12;
                if (br + bc == 0) nmask |= 10;
                if (wr + wc == 0) nmask |= 5;
                i64 &newVal = dp[i - wr - br][j - wc - bc][nmask];
                newVal += dp[i][j][mask] * coef;
                newVal %= P;
            }
        }
        mult[h][w] = res;
        if (h > 0) forn(mask, 16) mult[h][w] += dp[h][w][mask];
        mult[h][w] %= P;
    }

    i64 ans = 0;
    forn(rmask, 1 << n) forn(cmask, 1 << m) {
        if (min(rmask, cmask) == 0 && max(rmask, cmask) > 0) continue;
        bool ok = true;
        if (rmask != 0) {
            forn(i, n) {
                if (!((rmask >> i) & 1)) continue;
                bool hasB = false, hasW = false;
                forn(j, m) {
                    if (!((cmask >> j) & 1)) continue;
                    if (s[i][j] == '#') hasB = true;
                    else hasW = true;
                }
                if (!hasB || !hasW) ok = false;
            }

            forn(j, m) {
                if (!((cmask >> j) & 1)) continue;
                bool hasB = false, hasW = false;
                forn(i, n) {
                    if (!((rmask >> i) & 1)) continue;
                    if (s[i][j] == '#') hasB = true;
                    else hasW = true;
                }
                if (!hasB || !hasW) ok = false;
            }
        }
        if (!ok) continue;
        ans += mult[__builtin_popcount(rmask)][__builtin_popcount(cmask)];
        ans %= P;
    }    
    cout << ans << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}
	
### Prompt

Create a solution in cpp for the following problem:

We have an H \times W grid, where each square is painted white or black in the initial state. Given are strings A_1, A_2, ..., A_H representing the colors of the squares in the initial state. For each pair (i, j) (1 \leq i \leq H, 1 \leq j \leq W), if the j-th character of A_i is `.`, the square at the i-th row and j-th column is painted white; if that character is `#`, that square is painted black.

Among the 2^{HW} ways for each square in the grid to be painted white or black, how many can be obtained from the initial state by performing the operations below any number of times (possibly zero) in any order? Find this count modulo 998,244,353.

* Choose one row, then paint all the squares in that row white.
* Choose one row, then paint all the squares in that row black.
* Choose one column, then paint all the squares in that column white.
* Choose one column, then paint all the squares in that column black.

Constraints

* 1 \leq H, W \leq 10
* |A_i| = W (1 \leq i \leq H)
* All strings A_i consist of `.` and `#`.
* H and W are integers.

Input

Input is given from Standard Input in the following format:


H W
A_1
A_2
\vdots
A_H


Output

Print the answer.

Examples

Input

2 2
#.
.#


Output

15


Input

2 2
.
.#


Output

15


Input

3 3
...
...
...


Output

230


Input

2 4
...
...#


Output

150


Input

6 7
.......
.......
.#.....
..#....
.#.#...
.......


Output

203949910

### Response

```cpp
#include <bits/stdc++.h>

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

const int maxn = 10;
const i64 P = 998244353;
string s[maxn];

i64 mult[maxn + 1][maxn + 1];
i64 dp[maxn + 1][maxn + 1][16];
i64 cnk[maxn + 1][maxn + 1];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "rt", stdin);
#endif

    cnk[0][0] = 1;
    forn(i, maxn) forn(j, i + 1) forn(z, 2) cnk[i + 1][j + z] += cnk[i][j];

    int n, m;
    cin >> n >> m;
    forn(i, n) cin >> s[i];

    forn(h, n + 1) forn(w, m + 1) {
        if (min(w, h) == 0 && max(w, h) != 0) continue;
        forn(i, n + 1) forn(j, m + 1) forn(mask, 16) dp[i][j][mask] = 0;
        dp[n][m][0] = 1;
        i64 res = 0;
        ford(i, n + 1) ford(j, m + 1) forn(mask, 16) {
            if (i < h) continue;
            if (j < w) continue;
            if (dp[i][j][mask] == 0) continue;
//            if (h == 0) cerr << i << ' ' << j << ' ' << mask << ' ' << dp[i][j][mask] << '\n';
            if (min(i, j) == 0) {
                res += dp[i][j][mask];
                res %= P;
                continue;
            }
            forn(br, i - h + 1) forn(wr, i - h - br + 1) forn(bc, j - w + 1) forn(wc, j - w - bc + 1) {
                if ((mask & 1) && br > 0) continue;
                if ((mask & 2) && wr > 0) continue;
                if ((mask & 4) && bc > 0) continue;
                if ((mask & 8) && wc > 0) continue;
                if (br > 0 && wc > 0) continue;
                if (wr > 0 && bc > 0) continue;
                if (br + wr + bc + wc == 0) continue;
                if (wr == i && wc < j) continue;
                if (br == i && bc < j) continue;
                if (wc == j && wr < i) continue;
                if (bc == j && br < i) continue;

                i64 coef = cnk[i - h][br + wr] * cnk[br + wr][br] % P * cnk[j - w][bc + wc] % P * cnk[bc + wc][bc] % P;
                int nmask = 0;
                if (bc + wc == 0) nmask |= 3;
                if (br + wr == 0) nmask |= 12;
                if (br + bc == 0) nmask |= 10;
                if (wr + wc == 0) nmask |= 5;
                i64 &newVal = dp[i - wr - br][j - wc - bc][nmask];
                newVal += dp[i][j][mask] * coef;
                newVal %= P;
            }
        }
        mult[h][w] = res;
        if (h > 0) forn(mask, 16) mult[h][w] += dp[h][w][mask];
        mult[h][w] %= P;
    }

    i64 ans = 0;
    forn(rmask, 1 << n) forn(cmask, 1 << m) {
        if (min(rmask, cmask) == 0 && max(rmask, cmask) > 0) continue;
        bool ok = true;
        if (rmask != 0) {
            forn(i, n) {
                if (!((rmask >> i) & 1)) continue;
                bool hasB = false, hasW = false;
                forn(j, m) {
                    if (!((cmask >> j) & 1)) continue;
                    if (s[i][j] == '#') hasB = true;
                    else hasW = true;
                }
                if (!hasB || !hasW) ok = false;
            }

            forn(j, m) {
                if (!((cmask >> j) & 1)) continue;
                bool hasB = false, hasW = false;
                forn(i, n) {
                    if (!((rmask >> i) & 1)) continue;
                    if (s[i][j] == '#') hasB = true;
                    else hasW = true;
                }
                if (!hasB || !hasW) ok = false;
            }
        }
        if (!ok) continue;
        ans += mult[__builtin_popcount(rmask)][__builtin_popcount(cmask)];
        ans %= P;
    }    
    cout << ans << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}
	
```