#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pi 3.1415926535897932384626433832
#define endl "\n"
#define debug1(x) cout << #x << " = " << x << '\n';
#define debug2(x, y) cout << #x << " = " << x << "   " << #y << " = " << y << "\n";
#define debug3(x, y,z) cout << #x << " = " << x << "   " << #y << " = " << y << " "<<#z<<" = "<<z<<"\n";
#define f(i,n) for(int i=0;i<n;i++)
#define debugarr(arr) f(i,arr.size()) cout << arr[i] << " "; cout << endl;
#define debugarr2(arr) f(i,arr.size()){f(j,arr[i].size()) cout<<arr[i][j]<<" "; cout<<endl;}
#define pp pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define mod 998244353
ll gcd(ll a, ll b) {return a==0 ? b : gcd(b%a,a);}
bool sortcol(const vector<ll> &v1, const vector<ll> &v2){ return v1[1] < v2[1]; }


void solve()
{
  ll N;
  cin >> N;
  vector<ll> arr(N);
  f(i,N)cin>>arr[i];
}

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll t = 1;
  // cin >> t;
  vector<ll> ans(300001);
  vector<ll> add(300001);
  vector<ll> pow(300001);
  add[0] = 0;
  add[1] = 0;
  add[2] = 0;
  add[3] = 1;
  add[4] = 3;
  ll power = 4;
  for(int i = 5;i<300001;i++)
  {
    power*=2;
    power%=mod;
    add[i] = (power - add[i-1] + mod)%mod;
  }
  ans[0] = 0;
  ans[1] = 0;
  ans[2] = 1;
  for(int i = 3;i<300001;i++)
  {
    ans[i] = ans[i-1]*2;
    ans[i]%=mod;
    ans[i] += add[i]; 
  }
  pow[0] = 1;
  pow[1] = 2;
  for(int i = 2;i<300001;i++)
  {
    pow[i] = pow[i-1]*2;
    pow[i]%=mod;
  }
  while (t--)
  {
    ll N,M;
    cin>>N>>M;
    vector<string> s(N);
    ll finalans = 0;
    for(int i = 0;i<N;i++)
    {
      cin>>s[i];
    }
    ll count = 0;
    for(int i = 0;i<N;i++)
    {
      for(int j = 0;j<M;j++)
      {
        if(s[i][j] == 'o')
        {
          count++;
        }
      }
    }
    for(int i = 0;i<N;i++)
    {
      ll counthori = 0;
      for(int j = 0;j<M;j++)
      {
        if(s[i][j]=='o')
        {
          counthori++;
        }
        else
        {
          ll total = 1;
          total*=pow[count-counthori];
          total%=mod;
          total*=ans[counthori];
          total%=mod;
          finalans+=total;
          finalans%=mod;
          counthori = 0;
        }
      }
          ll total = 1;
          total*=pow[count-counthori];
          total%=mod;
          total*=ans[counthori];
          total%=mod;
          finalans+=total;
          finalans%=mod;
          counthori = 0;
    }
    for(int i = 0;i<M;i++)
    {
      ll counthori = 0;
      for(int j = 0;j<N;j++)
      {
        if(s[j][i]=='o')
        {
          counthori++;
        }
        else
        {
          ll total = 1;
          total*=pow[count-counthori];
          total%=mod;
          total*=ans[counthori];
          total%=mod;
          finalans+=total;
          finalans%=mod;
          counthori = 0;
        }
      }
      ll total = 1;
          total*=pow[count-counthori];
          total%=mod;
          total*=ans[counthori];
          total%=mod;
          finalans+=total;
          finalans%=mod;
          counthori = 0;
    }
  cout<<finalans<<endl;
  }
}

/*
_________________ IMP NOTES __________________
a = 97
A = 65
*/