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

Solution (in CPP):

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

#define ll long long
#define sd(x) scanf("%d", &(x))
#define pii pair<int, int>
#define F first
#define S second
#define all(c) ((c).begin()), ((c).end())
#define sz(x) ((int)(x).size())
#define ld long double

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<", "<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"{";
	for(int i = 0;i < (int)v.size(); i++){
		if(i)os<<", ";
		os<<v[i];
	}
	os<<"}";
	return os;
}

#ifdef LOCAL
#define cerr cout
#else
#endif

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

const int N = 10;
int dp[1 << N][1 << N][4][4];
char s[N][N];
const int mod = 998244353;

inline int add(int x, int y){ x += y; if(x >= mod) x -= mod; return x;}
inline int sub(int x, int y){ x -= y; if(x < 0) x += mod; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % mod;}
inline int powr(int a, ll b){
	int x = 1 % mod;
	while(b){
		if(b & 1) x = mul(x, a);
		a = mul(a, a);
		b >>= 1;
	}
	return x;
}
inline int inv(int a){ return powr(a, mod - 2);}

int num_bits[1 << N];


int main(){
	for(int i = 0; i < (1 << N); i++) num_bits[i] = __builtin_popcount(i);
	memset(dp, -1, sizeof dp);
	int n = 10, m = 10; 
	sd(n); sd(m);
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++) s[i][j] = rand() % 2 ? '.' : '.';
		scanf("%s", s[i]);
	}
	for(int mask1 = 1; mask1 < (1 << n); mask1++)
		for(int mask2 = 1; mask2 < (1 << m); mask2++){
			int ok = 1;
			for(int i = 0; i < 10; i++) if(mask1 >> i & 1){
				int msk = 0;
				for(int j = 0; j < 10; j++) if(mask2 >> j & 1) msk |= 1 << (s[i][j] == '.');
				if(msk != 3) ok = 0;
			}

			for(int i = 0; i < 10; i++) if(mask2 >> i & 1){
				int msk = 0;
				for(int j = 0; j < 10; j++) if(mask1 >> j & 1) msk |= 1 << (s[j][i] == '.');
				if(msk!=3) ok = 0;
			}
			dp[mask1][mask2][3][3] = ok;
		}
	for(int mask1 = 0; mask1 < (1 << n); mask1++)
		for(int mask2 = 0; mask2 < (1 << m); mask2++)
			for(int omust1 = 0; omust1 < 4; omust1++)
				for(int omust2 = 0; omust2 < 4; omust2++){
					if(mask1 == 0) dp[mask1][mask2][omust1][omust2] = omust2 == 0;
					if(mask2 == 0) dp[mask1][mask2][omust1][omust2] = omust1 == 0;
					if(min(mask1, mask2) == 0) continue;
					int must1 = omust1, must2 = omust2;
					if(must1 + must2 == 0 && (mask1 != ((1 << n) - 1) || mask2 != ((1 << m) - 1)))
						continue;
					if(((must1 == 3) || (must2 == 3) || (must1 + must2 == 0)) && (must1+must2!=6)){
						ll ret = 0;
						if(must1 != 3){
							for(int submask = mask1; submask; submask = mask1 & (submask - 1)){
								int num = num_bits[submask];
								if(!(must1 >> 1 & 1)){
									ret += dp[mask1 ^ submask][mask2][3][must2 & (~1)]; // white not required in cols now
								}

								if(!(must1 >> 0 & 1)){
									ret += dp[mask1 ^ submask][mask2][3][must2 & (~1)];; // black not required in cols now
								}

								if(must1 == 0) ret += ((1 << num) - 2) * (ll) dp[mask1 ^ submask][mask2][3][0]; // none required in cols now
							}
						}
						must1 = 3;
						if(must2 != 3){
							for(int submask = mask2; submask; submask = mask2 & (submask - 1)){
								int num = num_bits[submask];
								if(!(must2 >> 1 & 1)){
									ret += dp[mask1][mask2 ^ submask][must1 & (~1)][3]; // white not required in rows now
								}

								if(!(must2 >> 0 & 1)){
									ret += dp[mask1][mask2 ^ submask][must1 & (~2)][3]; // black not required in rows now
								}

								if(must2==0) ret += ((1 << num) - 2) * (ll) dp[mask1][mask2 ^ submask][0][3]; // none required in rows now
							}
						}
						ret += dp[mask1][mask2][3][3];
						dp[mask1][mask2][omust1][omust2] = ret % mod;
					}
				}
	printf("%d\n", dp[(1 << n) - 1][(1 << m) - 1][0][0]);
}