#include <bits/stdc++.h>
#define mod 998244353
using namespace std;

template<typename T> inline T add(const T &x, const T &y) {
  T res = x + y;
  if (res > mod) res -= mod;
  return res;
}

int main() {
  int n, m;
  scanf("%d%d",&n,&m);
  getchar();
  int N = max(n, m);
  vector<int> p(n * m + 1, 1);
  for (int i = 1; i <= n * m; i++)
    p[i] = p[i - 1] * 2 % mod;
  vector<vector<int> > f(N + 1, vector<int>(2, 0));
  f[2][1] = 1;
  for (int i = 3; i <= N; i++) {
    f[i][0] = add(f[i-1][0], f[i-1][1]);
    f[i][1] = add(add(f[i-1][0], p[i-2]), add(f[i-2][0], f[i-2][1]));
  }
  vector<vector<char> > mp(n + 1, vector<char>(m + 1));
  int tot = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      mp[i][j] = getchar();
      tot += (mp[i][j] == 'o');
    }
    getchar();
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    int cnt = 0;
    for (int j = 1; j <= m; j++) {
      if (mp[i][j] != 'o') {
        if (cnt >= 2) {
          ans = add(ans, (long long)add(f[cnt][0], f[cnt][1]) * p[tot - cnt] % mod);
        }
        cnt = 0;
      } else ++cnt;
    }
    if (cnt >= 2) ans = add(ans, (long long)add(f[cnt][0], f[cnt][1]) * p[tot - cnt] % mod);
  }
  for (int i = 1; i <= m; i++) {
    int cnt = 0;
    for (int j = 1; j <= n; j++) {
      if (mp[j][i] != 'o') {
        if (cnt >= 2) ans = add(ans, (long long)add(f[cnt][0], f[cnt][1]) * p[tot - cnt] % mod);
        cnt = 0;
      } else ++cnt;
    }
    if (cnt >= 2) ans = add(ans, (long long)add(f[cnt][0], f[cnt][1]) * p[tot - cnt] % mod);
  }
  printf("%lld\n",ans);
  return 0;
}  