// by GolD_Batyr
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define y1 y1234567890

#define NAME ""
#define fast_io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file_io freopen(NAME".in", "r", stdin); freopen(NAME".out", "w", stdout)

const int N = 1e5;
const int M = N + 7;
const double EPS = 1e-10;

const int MOD = 998244353;
const ll INF = 1e18 + 17;

int n, m;
int c[100];
ll ans;

ll bip(ll x, ll n, ll MOD) {
  ll res = 1;
  while (n) {
    if (n & 1) res = res * x % MOD;
    x = x * x % MOD;
    n /= 2; 
  } 
  return res;
}

ll mult(ll x, ll y) {
  return x * y % MOD;
}

ll dv(ll x, ll y) {
  return x * bip(y, MOD - 2, MOD) % MOD;
}

ll sub(ll x, ll y) {
  return (x - y + MOD) % MOD;
}

ll add(ll x, ll y) {
  return (x + y) % MOD;
}

void rec(int v) {
  if (v > n) {
    int l = 0;
    for (int i = 1; i <= n; i++) {
      if (c[i] == 1) l++;
      else {
        ans += l / 2;
        l = 0;
      }
    }
    ans += l / 2;
    return;
  }
  c[v] = 1;
  rec(v + 1);
  c[v] = 0;
  rec(v + 1);
}

ll f(int n) {
  if (n == 0) return 0;
  n--;
  ll res = 0;
  if (n & 1) {
    res = dv(mult((3 * n + 1), bip(2, n, MOD)) + 1, 9);
  } else {
    res = dv(mult((3 * n + 1), bip(2, n, MOD)) - 1, 9);
  }
  return res;
}

void solve() {  
  cin >> n >> m;
  
  int w = 0;
  vector <vector <char>> a(n, vector<char>(m));
  for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) {
    cin >> a[i][j];  
    if (a[i][j] == 'o') w++;
  }

  //cout << w << endl;
  for (int i = 0; i < n; i++) {
    int l = 0;
    for (int j = 0; j < m; j++) {
      if (a[i][j] == 'o') l++;
      else {
        //cout << l << endl;
        //ans += f(l) * bip(2, w - l, MOD) % MOD;
        //cout << f(l) << ' ' << bip(2, w - l, MOD) << endl;
        ans = add(ans, mult(f(l), bip(2, w - l, MOD)));
        l = 0;
      }
    }
    //cout << l << endl;
    //cout << f(l) << ' ' << bip(2, w - l, MOD) << endl;
    //ans += f(l) * bip(2, w - l, MOD) % MOD;
    ans = add(ans, mult(f(l), bip(2, w - l, MOD)));
    l = 0;
  }
  //cout << ans << endl;
  //return;
  for (int j = 0; j < m; j++) {
    int l = 0;
    for (int i = 0; i < n; i++) {
      if (a[i][j] == 'o') l++;
      else {
        ans = add(ans, mult(f(l), bip(2, w - l, MOD)));
        l = 0;
      }
    }
    ans = add(ans, mult(f(l), bip(2, w - l, MOD)));
    l = 0;
  }  
  cout << ans;
}

int main() {
  fast_io;
  int tt = 1;
  //cin >> tt;
  while (tt--) {
    solve();
  }
  return 0;
}