#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define fo(i,n) for(ll i=0;i<n;i++)
#define fo1(i,n) for(ll i=1;i<=n;i++)
#define loop(i,a,b)for(ll i=a;i<=b;i++)
#define loopr(i,a,b)for(ll i=b;i>=a;i--)
#define all(x) x.begin(), x.end()
#define sz(x) (ll)(x).size()
#define vll vector<ll> 
#define vvl vector<vll>
#define vpll vector<pll>
#define pll pair<ll,ll>
#define F first
#define S second
#define MOD 1000000007
ll max(ll a,ll b){if (a>b) return a; else return b;}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b, a%b);}
ll lcm(ll a, ll b){return a*b/gcd(a, b);}
ll fexp(ll a, ll b){ll ans = 1;while(b){if(b&1) ans = ans*a%MOD; b/=2;a=a*a%MOD;}return ans;}
ll inverse(ll a, ll p){return fexp(a, p-2);}
using namespace std;

//take care of long long

//fast I/O 
auto optimizer = []() {  // makes I/O fast
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  return 0;
}();

//seive
ll N = 1e5;
vll lpf(N+1,0);
void leastPrimeFactor()
{
    lpf[1] = 1;
    for (ll i = 2; i <= N; i++)
    {
        if(lpf[i] == 0)
        {
            lpf[i] = i;
            for (ll j = 2*i; j <= N; j += i)
            	if (lpf[j] == 0)
                	lpf[j] = i;
        } 
    }
}

int main()
{
	ll t=1;
	//cin>>t;
	while(t--)
	{
		ll a,b;
		cin>>a>>b;
	    double c=a*b;
	    c/=100;
		cout<<c<<endl;
	}
	return 0;
}
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define Pr pair<ll,ll>
#define Tp tuple<ll,ll,ll>
using Graph = vector<vector<int>>;

ll mod = 998244353;


//累乗 aのb乗、正しmを法として求める
long long pw(long long a,long long b,long long m){
    if(b==0) return 1;
    else if(b%2==0){
        long long x = pw(a,b/2,m);
        return (x*x)%m;
    }
    else{
        long long x = pw(a,b-1,m);
        return (a*x)%m;
    }
}



int main() {
    ll H,W; cin >> H >> W;
    char gr[H][W];
    rep(i,H){
        rep(j,W) cin >> gr[i][j];
    }
    bool ok = true; ll fr = 0;
    for(int i=0;i<=H+W-2;i++){
        bool fixed = false; char col; ll cnt = 0;
        rep(j,H){
            if(i-j<0) break;
            if(i-j>=W) continue;
            int k = i-j;
            if(gr[j][k]=='.'){
                cnt++;
            }
            else{
                if(!fixed){
                    fixed = true; col = gr[j][k];
                }
                else{
                    if(col!=gr[j][k]){
                        ok = false;
                    }
                }
            }
        }
        if(!fixed) fr++;
    }
    ll ans = pw(2LL,fr,mod);
    if(!ok) ans = 0;
    cout << ans <<  endl;
}