#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

typedef long long ll;

int main() {
    ll MOD = 1e9 + 7;
    int H, W, K = 0;
    cin >> H >> W;
    vector<string> S(H);
    rep(i, H) {
        cin >> S[i];
        rep(j, W) {
            if (S[i][j] == '.') K++;
        }
    }
    //cout << "K=" << K << "\n";
    vector<vector<int>> R(H, vector<int>(W + 1, 0)), C(H + 1, vector<int>(W, 0));
    rep(i, H) {
        rep(j, W) {
            if (S[i][j] == '.') R[i][j + 1] = R[i][j] + 1;
        }
        for (int j = W - 2; j >= 0; j--) {
            if (S[i][j] == '.') R[i][j + 1] = max(R[i][j + 1], R[i][j + 2]);
        }
        //rep(j, W) cout << R[i][j + 1];
        //cout << "\n";
    }
    rep(j, W) {
        rep(i, H) {
            if (S[i][j] == '.') C[i + 1][j] = C[i][j] + 1;
        }
        for (int i = H - 2; i >= 0; i--) {
            if (S[i][j] == '.') C[i + 1][j] = max(C[i + 1][j], C[i + 2][j]);
        }
    }
    /*
    rep(i, H) {
        rep(j, W) {
            cout << C[i + 1][j];
        }
        cout << "\n";
    }
    */
    vector<ll> b(4000001, 1);
    rep(i, 4000000) b[i + 1] = (b[i] * 2) % MOD;
    ll ans = 0;
    rep(i, H) {
        rep(j, W) {
            if (S[i][j] == '#') continue;
            int B = R[i][j + 1] + C[i + 1][j] - 1;
            //cout << "B=" << B << "\n";
            ans = (ans + ((b[B] - 1 + MOD) % MOD) * b[K - B]) % MOD;
        }
    }
    cout << ans << "\n";
}
#include<bits/stdc++.h>
#define LL long long
using namespace std;
const int mod=998244353;
int n,m;
LL fact[200010],inv[200010],f[200010][20],ans;
inline int read()
{
	int x=0,w=0;char ch=0;
	while(!isdigit(ch)){w|=ch=='-';ch=getchar();}
	while(isdigit(ch)){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
	return w?-x:x;
}
LL ksm(LL B,LL K,LL A=1)
{
	for(;K;K>>=1,B=B*B%mod)
	if(K&1)A=A*B%mod;
	return A;
}
void prepare()
{
	fact[0]=1;
	for(int i=1;i<=200000;i++)fact[i]=fact[i-1]*i%mod;
	inv[200000]=ksm(fact[200000],mod-2);
	for(int i=200000-1;i>=0;i--)
		inv[i]=inv[i+1]*(i+1)%mod;
}
LL C(LL N,LL M)
{
	if(N<M||M<0)return 0;
	return fact[N]*inv[M]%mod*inv[N-M]%mod;
}
int main()
{
	prepare();
	n=read();m=read();
	for(int i=1;i<=m;i++)
		f[i][0]=1;
	//f[i][j] 表示 a[n]=i,并且变了j次的方案数。
	for(int t=0;t<=18;t++)
	for(int i=1;i<=m;i++)
	for(int j=2*i;j<=m;j+=i)
		f[j][t+1]=(f[j][t+1]+f[i][t])%mod;
	for(int i=0;i<=min(18,n);i++)
	for(int j=1;j<=m;j++)
		ans=(ans+f[j][i]*C(n-1,i))%mod;
	cout<<ans<<'\n';
}