#include<bits/stdc++.h>
using namespace std;
#define long long long 
int n, m;
vector<vector<int> > A;
long pw[300003];
const long MOD = 998244353;

long dp[300003][2], com[300003][2];
void count()
{
	com[0][0] = 1;
	for(int i = 1; i <= 300000; i++)
	{
		com[i][1] = com[i-1][0];
		dp[i][1] = dp[i-1][0];
		com[i][0] = (2*com[i-1][1]+com[i-1][0])%MOD;
		dp[i][0] = (dp[i-1][0]+2*dp[i-1][1]+com[i-1][1])%MOD;
	}
	// for(int i = 0; i <= 10; i++)
	// 	printf("%lld ", dp[i][0]+dp[i][1]);
	// printf("\n");
	// for(int i = 0; i <= 10; i++)
	// 	printf("%lld ", com[i][0]+com[i][1]);
	// printf("\n");
}

int main()
{
	count();
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	// freopen("input.in", "r", stdin);

	pw[0] = 1;
	for(int i = 1; i <= 300000; i++)
		pw[i] = (pw[i-1]+pw[i-1])%MOD;

	scanf("%d %d\n", &n, &m);
	A = vector<vector<int>>(n+5, vector<int> (m+5));
	int hit = 0;
	for(int i = 1; i <= n; i++)
	{
		for(int j = 1; j <= m; j++)
		{
			char c; scanf("%c", &c);
			A[i][j] = (c == 'o');
			hit += A[i][j];
		}
		scanf("\n");
	}
	long res = 0;
	int cnt = 0;
	for(int i = 1; i <= n; i++)
	{
		for(int j = 1; j <= m+1; j++)
		{
			if(A[i][j] == 0)
			{
				res = (res+((dp[cnt][0]+dp[cnt][1])*pw[hit-cnt])%MOD)%MOD;
				cnt = 0;
			}
			else cnt++;
		}
	}
	cnt = 0;
	for(int i = 1; i <= m; i++)
	{
		for(int j = 1; j <= n+1; j++)
		{
			if(A[j][i] == 0)
			{
				res = (res+((dp[cnt][0]+dp[cnt][1])*pw[hit-cnt])%MOD)%MOD;
				cnt = 0;	
			}
			else cnt++;
		}
	}
	printf("%lld\n", res);

}