#include<cstdio>
const long long mod = 998244353;
long long f[15], invf[15];
long long f0[15][15][2];
long long f1[15][15];
long long sum[15][15];
char s[15];
int a[15][15];
int b[15][15];
int cnt[2005];

long long power(long long a,long long b){
    long long res = 1;
    while(b){
        if(b&1) res = res*a%mod;
        a = a*a%mod;
        b /= 2;
    }
    return res;
}

long long inv(long long u){ return power(u,mod-2); }

void preWork(int n){
    f[0] = invf[0] = 1;
    for(long long i = 1; i <= n; i++){
        f[i] = f[i-1]*i%mod;
        invf[i] = inv(f[i]);
    }
    for(int i = 0; i < (1<<10); i++){
        cnt[i] = 0;
        int mask = i;
        while(mask){
            cnt[i] += mask%2;
            mask /= 2;
        }
    }
}

long long getC(int n,int m){
    if(m>n || m<0) return 0;
    else{
        long long res = f[n];
        res = res*invf[m]%mod;
        res = res*invf[n-m]%mod;
        return res;
    }
}

int check(int n,int m){
    for(int i = 1; i <= n; i++){
        int cnt0 = 0, cnt1 = 0;
        for(int j = 1; j <= m; j++){
            if(b[i][j]!=-1){
                if(b[i][j]==0) cnt0++;
                else cnt1++;
            }
        }
        if(!cnt0 && cnt1) return 0;
        if(!cnt1 && cnt0) return 0;
    }
    for(int j = 1; j <= m; j++){
        int cnt0 = 0, cnt1 = 0;
        for(int i = 1; i <= n; i++){
            if(b[i][j]!=-1){
                if(b[i][j]==0) cnt0++;
                else cnt1++;
            }
        }
        if(!cnt0 && cnt1) return 0;
        if(!cnt1 && cnt0) return 0;
    }
    return 1;
}

int main(){
    preWork(10);
    f0[0][0][0] = f0[0][0][1] = 1;
    for(int i = 0; i <= 10; i++){
        for(int j = 0; j <= 10; j++){
            if(i || j){
                f0[i][j][0] = f0[i][j][1] = 0;
                for(int k = i-1; k >= 0; k--) f0[i][j][0] = (f0[i][j][0] + f0[k][j][1]*invf[i-k]%mod)%mod;
                for(int k = j-1; k >= 0; k--) f0[i][j][1] = (f0[i][j][1] + f0[i][k][0]*invf[j-k]%mod)%mod;
            }
            if(i==0 && j==0) f1[i][j] = 1;
            else{
                f1[i][j] = (f0[i][j][0]+f0[i][j][1])%mod;
                f1[i][j] = f1[i][j]*f[i]%mod;
                f1[i][j] = f1[i][j]*f[j]%mod;
            }
            //printf("f1[%d][%d] = %lld\n",i,j,f1[i][j]);
        }
    }
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i = 1; i <= n; i++){ 
        scanf("%s",s+1);
        for(int j = 1; j <= m; j++){ 
            a[i][j] = s[j]=='.';
        }
    }
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            sum[i][j] = 0;
            for(int x = 0; x <= i; x++){
                for(int y = 0; y <= j; y++){
                    long long count = getC(i,x)*getC(j,y)%mod;
                    //black or white = column and row diff from color
                    count = count*f1[x][y]%mod;
                    count = count*f1[i-x][j-y]%mod;
                    sum[i][j] = (sum[i][j]+count)%mod;
                }
            }
        }
    }
    long long ans = f1[n][m];
    for(int i = 0; i < (1<<n); i++){
        for(int j = 0; j < (1<<m); j++){
            if(!i && !j) continue;
            for(int k = 0; k < n; k++){
                for(int l = 0; l < m; l++){
                    if(i&(1<<k) && j&(1<<l)) b[k+1][l+1] = a[k+1][l+1];
                    else b[k+1][l+1] = -1;
                    //if(i==3 && j==9) printf("%2d",b[k][l]);
                }
                //if(i==3 && j==9) printf("\n");
            }
            if(check(n,m)!=0){ 
                //printf("i = %d, j = %d\n",i,j);
                ans = (ans+sum[n-cnt[i]][m-cnt[j]])%mod;
            }
        }
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 128