
#include <bits/stdc++.h>
using namespace std;
#define ll  long long
#define int ll
#define vi vector<int>
#define pii pair<ll,ll>
#define piii pair<int, pii>
#define pb push_back
#define fs first
#define sc second
//#define ONLINE_JUDGE
#define endl "\n"
#define pow2(i) (1<<(i))  
#define d0(x) cout<<x<<" "
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<x<<" "<<y<<" "<<z<<endl
#define d4(x,y,z,w) cout<<x<<" "<<y<<" "<<z<<" "<<w<<endl
#define d5(x,y,z,w,s) cout<<x<<" "<<y<<" "<<z<<" "<<w<<" "<<s<<endl
#define fifo ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define precise(x) cout<<fixed<<setprecision(x)
#define all(v) (v).begin(),(v).end()
const ll mod =   998244353;


int dp[300001][3]; int cnt[300001]; int p[300001];int ans[300001];vi v[300001];
void solve()
{
	dp[0][0]=1;
	dp[0][1]=0;
	dp[0][2]=0;
	ans[0]=0;
	p[0]=1;
	for(int i=1;i<=300000;i++)
	{
		ans[i] = (2*ans[i-1]+dp[i-1][1])%mod;
		dp[i][1] = dp[i-1][0]+dp[i-1][2];
		dp[i][0] = dp[i-1][2]+dp[i-1][1]+dp[i-1][0];
		dp[i][2] = dp[i-1][1];

		for(int j=0;j<3;j++)
			dp[i][j]%=mod;

		p[i]= (p[i-1]*2)%mod;
	}

	int n,m;cin>>n>>m;
	for(int i=0;i<=n;i++)
		v[i].resize(m);
	for(int i=0;i<=n;i++)
		for(int j=0;j<=m;j++)
			v[i][j]=0;
	int tot = 0;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
		{
			char c;
			cin>>c;
			if(c=='o')
			{
				tot++;
				v[i][j]=1;
			}
		}

	/*for(int i=0;i<=n;i++)
		for(int j=0;j<=m;j++)
			cout<<v[i][j]<<(j==m?"\n":"");
*/
	int ret = 0;
	for(int i=0;i<=n;i++)
		for(int j=0;j<=m;j++)
		{
			if(v[i][j]==0)
			{
				int crr = 0;
				for(int k=j+1;k<=m;k++)
				{
					if(v[i][k]==0)break;
					crr++;
				}
				ret = (ret+ans[crr]*p[tot-crr])%mod;
				//if(crr>0)d3(i,j,crr);
				crr = 0;
				for(int k=i+1;k<=n;k++)
				{
					if(v[k][j]==0)break;
					crr++;
				}
				ret = (ret+ans[crr]*p[tot-crr])%mod;
				//if(crr>0)d3(i,j,crr);
			}
		}

	d1(ret);

}
 
 
signed main()
{
    #ifndef ONLINE_JUDGE
   freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #endif
 
    fifo
    int tt=1;
 
  // cin>>tt;
 	//d1(tt);
 	//d1(f00());
    for(ll tc=1;tc<=tt;++tc)
    {
    	//cout<<"Case #"<<tc<<": ";
        solve();
    }
}