// Problem: E. Colorings and Dominoes
// Contest: Codeforces - Educational Codeforces Round 107 (Rated for Div. 2)
// URL: https://codeforces.com/contest/1511/problem/E
// Memory Limit: 512 MB
// Time Limit: 3000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll power(ll x,ll y,ll m){if(y==0)return 1;ll p=power(x,y/2,m)%m;p=(p*p)%m;return (y%2==0)?p:(x*p)%m;}
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());int get_rand(int l, int r){uniform_int_distribution<int> uid(l,r);return uid(rng);}
vector<ll> Fac(1,1);int Last_Index = 0;
ll nCr(ll n,ll r,ll m){if(r>n) return 0;if(n>Last_Index){for(ll i=Last_Index+1;i<=n;++i){Fac.push_back(Fac[i-1]*i);Fac[i]%=m;}Last_Index=n;}return (((Fac[n]*power(Fac[r],m-2,m))%m)*power(Fac[n-r],m-2,m))%m;}ll gcd(ll a, ll b) {return (b ? gcd(b, a % b) : a);}
#define Test int t;cin>>t;while(t--)
#define endl '\n'
int Google_Test;
#define int ll
int mod = 998244353;
void solve()
{
	// cout << "Case #" << ++Google_Test << ": ";
	int n,m;
	cin >> n >> m;
	vector<string> s(n);
	for(int i=0;i<n;++i)
	cin >> s[i];
	int cnt=0;
	for(int i=0;i<n;++i)
	{
		for(int j=0;j<m;++j)
		{
			if(s[i][j]=='o')
			cnt++;
		}
	}
	if(cnt<=1)
	{
		cout << 0 << endl;
		return;
	}
	vector<int> temp;
	for(int i=0;i<n;++i)
	{
		int tcnt=0;
		for(int j=0;j<m;++j)
		{
			if(s[i][j]=='o')
			tcnt++;
			else
			{
				temp.push_back(tcnt);
				tcnt=0;
			}
		}
		temp.push_back(tcnt);
	}
	for(int j=0;j<m;++j)
	{
		int tcnt=0;
		for(int i=0;i<n;++i)
		{
			if(s[i][j]=='o')
			tcnt++;
			else
			{
				temp.push_back(tcnt);
				tcnt=0;
			}
		}
		temp.push_back(tcnt);
	}
	vector<int> ans(cnt+1);
	int tsum = 0;
	for(int i=2;i<=cnt;++i)
	{
		ans[i] = (ans[i-1] + tsum)%mod;
		if(i%2)
		{
			ans[i] = (ans[i] - power(2,(cnt-2)-(i-2),mod) + mod)%mod;
			tsum = (tsum - power(2,(cnt-2)-(i-2),mod) + mod)%mod;
		}
		else
		{
			ans[i] = (ans[i] + power(2,(cnt-2)-(i-2),mod))%mod;
			tsum = (tsum + power(2,(cnt-2)-(i-2),mod))%mod;
		}
	}
	// for(int i=2;i<=4;++i)
	// cout << ans[i] << " ";
	int fans = 0;
	for(int i:temp)
	{
		if(i<=1)
		continue;
		fans += ans[i];
		fans %= mod;
	}
	cout << fans << endl;
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//Test
	solve();
	return 0;
}
