#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define ll long long
#define ld long double
#define pii pair <int,int>
#define pll pair <ll,ll>
#define pil pair <int,ll>
#define pli pair <ll,int>
#define pss pair <short,short>
#define ull unsigned long long
#define pdd pair <ld,ld> 
#define pb push_back
#define mp make_pair
#define puu pair<ull,ull>
#define pvv pair<vector<int>, vector<int> >
#define _bp __builtin_popcount
#define ptt pair <pnode,pnode>
#define all(v) v.begin(),v.end()
#define en "\n"
void file()
{
    freopen("input.txt","r",stdin);
    freopen("f.txt","w",stdout);
}
void boos()
{
	ios_base :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
//const long double pi = acos(-1);
const ll INF = (ll)1e9 + 7ll;
const ll INF1 = 998244353;
const ll INF2 = (ll)1e9 + 9ll;
const ll LLINF = (ll)1e18;
const ll INTmx = (ll)1e9;
const ld EPS = (ld)1e-15;
const int N = 3e5 + 100;
string a[N];
ll st[N],dp[N],dp1[N],dp2[N];
int main()
{
	boos();
	//file();
	int n,m;
	cin >> n >> m;
	int k = 0;
	for(int i = 1;i <= n;i++)
	{
		cin >> a[i];
		a[i] = "0" + a[i];
		for(int j = 1;j <= m;j++)
		{
			if(a[i][j] == 'o')k++;
		}
	}
	st[0] = 1;
	dp1[0] = 1;
	for(int i = 1;i <= k;i++)
	{
		st[i] = (st[i - 1] * 2ll) % INF1;
	}
	dp2[2] = 1;
	dp1[2] = 1;
	for(ll i = 3;i <= max(n,m);i++)
	{
		dp[i] = (dp[i - 2] + (st[i - 3] * (i - 2)) % INF1) % INF1;
		if(i % 2 == 0)dp1[i] = (dp1[i - 1] * 2ll + 1ll) % INF1;
		else dp1[i] = (dp1[i - 1] * 2ll) % INF1;
		dp2[i] = dp[i];
		dp2[i] = (dp2[i] + dp1[i]) % INF1;
	}
	//cout << dp2[3] << " " << k << " " << st[k - 2] << en;
	ll ans = 0;
	for(int i = 1;i <= n;i++)
	{
		int L = 1;
		for(int j = 1;j <= m;j++)
		{
			if(a[i][j] == '*')
			{
				if(L != j)
				{
					ans += (dp2[j - L] * st[k - (j - L)]) % INF1;
					//ans += (st[j - L - 2] * st[k - (j - L)]) % INF1;
					//cout << j - L << " ";
					ans %= INF1;
				}
				L = j + 1;
			}
		}
		if(L != m + 1)
		{
			ans += (dp2[m - L + 1] * st[k - (m - L + 1)]) % INF1;
			//ans += (st[m - L - 1] * st[k - (m - L + 1)]) % INF1;
			//cout << m - L + 1 << " ";
			ans %= INF1;
		}
	}
	//cout << dp[4] << en;
	for(int j = 1;j <= m;j++)
	{
		int L = 1;
		for(int i = 1;i <= n;i++)
		{
			if(a[i][j] == '*')
			{
				if(L != i)
				{
					ans += (dp2[i - L] * st[k - (i - L)]) % INF1;
					//ans += (st[i - L - 2] * st[k - (i - L)]) % INF1;
					//cout << i - L << " ";
					ans %= INF1;
				}
				L = i + 1;
			}
		}
		if(L != n + 1)
		{
			ans += (dp2[n - L + 1] * st[k - (n - L + 1)]) % INF1;
			//ans += (st[n - L - 1] * st[k - (n - L + 1)]) % INF1;
			//cout << n- L + 1 << " ";
			ans %= INF1;
		}
	}
	cout << ans;
}