#include<bits/stdc++.h>
#define ls p<<1
#define rs p<<1|1 
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define mm make_pair
#define pi 2*acos(0.0)
#define lcm(a,b) (a*b)/__gcd(a,b)
#define cp(i,ans) printf("%.if",ans);
#define cpp(i,ans) cout.precision(i);cout<<fixed<<ans<<endl;
#define lowbit(x) (x)&(-x)
#define out(x) {cout<<x<<endl;return 0;} 
#define all(v) v.begin(),v.end() 
#define mem(x,i) memset(x,i,sizeof(x)) 
#define mec(x,y) memcpy(x,y,sizeof(y))
#define eps 1e-8 
#define ull unsigned long long
#define cps CLOCKS_PER_SEC
using namespace std;
typedef long long ll;
const int mod=998244353;
const int inf=0x3f3f3f3f;
ll gcd(ll x,ll y){if(y==0) return x;else return gcd(y,x%y);} 
ll ksm(ll a,ll b){ll r=1;while(b){if(b&1) r=(r*a)%mod;a=a*a%mod;b>>=1;}return r;} 
void exgcd(ll a, ll b, ll &x, ll &y, ll &d){if(!b) d=a,x=1,y=0;else exgcd(b,a%b,y,x,d),y-=a/b*x;}
ll inv(ll a, ll p){ll x,y,d;exgcd(a,p,x,y,d);x=(x%p+p)%p;return x;}
inline int read()
{
    char c=getchar();int x=0,f=1;
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}
const int maxn=3e5+100;
int n,m,k,t;
string s[maxn];
int all=0;
vector<int> h;
ll dp[maxn];
ll sum[2]={1,1};
ll work(vector<int> &h){
	dp[2]=1;dp[3]=3;
	for(int i=4;i<maxn;i++){
		sum[i%2]=(sum[i%2]+ksm(2,i-3))%mod;
		dp[i]=(2ll*dp[i-1]%mod+sum[i%2])%mod;
	}
	ll ans=0;
	for(int it:h){
		if(it<2) continue;
		int res=all-it;
		ans=(ans+dp[it]*ksm(2,res)%mod)%mod;
	}
	return ans;
}
int main()
{
	fast;
	cin>>n>>m;
	for(int i=0;i<n;i++) cin>>s[i];
	for(int i=0;i<m;i++) s[n]+='#';
	
	for(int i=0;i<n;i++){
		int cnt=0;s[i]+='#';
		for(int j=0;j<m+1;j++){
			if(s[i][j]=='o'){
				cnt++;all++;
			}
			else{
				if(cnt) h.push_back(cnt),cnt=0;
			}
		}
	}
	
	for(int j=0;j<m;j++){
		int cnt=0;
		for(int i=0;i<n+1;i++){
			if(s[i][j]=='o'){
				cnt++;
			}
			else{
				if(cnt) h.push_back(cnt),cnt=0;
			}
		}
	} 
	ll ans=work(h);
	cout<<ans<<endl;
	
	return 0;
}