#include <bits/stdc++.h>
#define INF (ll)(1e18 + 7)
#define MD (ll)(1e9 + 7)

using namespace std;
using ll = long long;
using cd = complex<double>;
using ul = unsigned long;

const ll MAX  = 3e5 + 5;
const ll MOD = 998244353;
void f_io () { ios_base :: sync_with_stdio (false);
 cin.tie (nullptr);
 cout.tie (nullptr);
}

const ll N = 10000000;

ll mult (ll a, ll b) {
	return (a * 1LL * b) % MOD;
}

ll add (ll a, ll b)  {
	b = ((b % MOD + MOD) % MOD);
	return (a + b) % MOD;
}

ll pw (ll a, ll b) {
	ll r = 1;
	while (b) {
		if (b & 1) {
			r = mult (a, r);
		}
		b >>= 1;
		a = mult (a, a);
	}
	return r;
}
ll gc (ll a, ll y) {	
	if (!a || !y) {
		return max (a, y);
	}
	ll r = a % y;
	while (r) {
		a = y;
		
		r = a % y;
	}
	return y;
}

ll extended_gcd (ll x, ll y) {
	ll ax = 1, ay = 0, bx = 0, by = 1;
	ll r = (x % y);
	while (r) {
		ll a1, a2, b1, b2;
		a1 = bx, a2 = by;
		ll q = (x / y);
		b1 = ax - q * bx, b2 = ay - q * by;
		ax = a1, ay = a2, bx = b1, by = b2;
		x = y;
		y = r;
		r = x % y;
	}
	return bx;
}

ll dp[MAX][2], d2[MAX][2];

int main () {
	ll n, m;
	cin >> n >> m;
	dp[0][0] = 1;
	for (ll i = 0; i + 1 < MAX; i++) {
		for (ll j = 0; j < 2; j++) {
			dp[i + 1][0] = add (dp[i][j], dp[i + 1][0]);
			d2[i + 1][0] = add (d2[i][j], d2[i + 1][0]);
			if (i + 2 < MAX && j == 0) {
				dp[i + 2][j] = add (dp[i + 2][j], dp[i][j]);
				d2[i + 2][j] = add (d2[i + 2][j], add (d2[i][j], dp[i][j]));
			}
		}
		dp[i + 1][1] = add (dp[i + 1][1], dp[i][0]);
		d2[i + 1][1] = add (d2[i + 1][1], d2[i][0]);
	}
	string vs[n + 1];
	string s;
	for (ll i = 0; i < m; s += '*', i++);
	ll cc = 0;
	for (ll i = 0; i < n; i++) {
		cin >> vs[i];
		vs[i] += '*';
		for (auto x : vs[i]) {
			cc += x == 'o';
		}
	}
	vs[n] = s;
	ll ans = 0;
	for (ll i = 0; i < n; i++) {
		ll c = 0;
		for (ll j = 0; j <= m; j++) {
			if (vs[i][j] == '*') {
				ans = add (mult (d2[c][0] + d2[c][1], pw (2, cc - c)), ans);
				c = 0;
			}
			else {
				c++;
			}
		}
	}
	for (ll j = 0; j < m; j++) {
		ll c = 0;
		for (ll i = 0; i <= n; i++) {
			if (vs[i][j] == '*') {
				ans = add (mult (d2[c][0] + d2[c][1], pw (2, cc - c)), ans);
				c = 0;
			}
			else {
				c++;
			}
		}
	}
	cout << ans << "\n";
}
				
