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

typedef long long ll;
typedef long double ld;
typedef double db;

typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef pair<pii, int> piipi;
typedef pair<int, pii> pipii;
typedef pair<pii, pii> piipii;
typedef pair<ll, pii> plpii;
typedef pair<db, db> pdd;
typedef pair<ld, ld> pldd;

#define mp make_pair
#define fi first
#define se second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define eb emplace_back
#define pf push_front
#define pb push_back

// const int mod = 998244353;
const int P1 = 999983, P2 = 999979;
const ld PI = acos((ld)-1);
const int mod = 998244353;
const int dir[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
const ll INF = 1e18;
const int N = 1e6+5;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

char c[300005];
vector<char> s[300005];
vector<int> sumR[300005], sumL[300005], sumU[300005], sumD[300005];
ll dp1[300005], dp2[300005];
ll pw[300005];
int main(){
    int n, m;
    scanf("%d%d", &n, &m);
    pw[0] = 1;
    for(int i=1;i<=n*m;i++) pw[i] = pw[i-1]*2%mod;
    for(int i=0;i<=n+2;i++){
        s[i].resize(m+2);
        sumR[i].resize(m+2);
        sumL[i].resize(m+2);
        sumU[i].resize(m+2);
        sumD[i].resize(m+2);
    }
    int sum = 0;
    for(int i=1;i<=n;i++){
        scanf("%s", c+1);
        for(int j=1;j<=m;j++){
            s[i][j] = c[j];
            if(s[i][j] == 'o'){
                sum++;
                sumL[i][j] = sumL[i][j-1] + 1;
                sumU[i][j] = sumU[i-1][j] + 1;
            }
        }
    }

    for(int i=1;i<=n*m;i++){
        if(sum-i-2 >= 0){
            dp1[i] += (i/2)*1ll*pw[sum-i-2]%mod;
            dp1[i] += dp1[i-1];
            dp1[i] %= mod;
        }
        if(sum-i-1 >= 0){
            dp2[i] += (i/2)*1ll*pw[sum-i-1]%mod;
            dp2[i] += dp2[i-1];
            dp2[i] %= mod;
        }
    }

    for(int i=n;i>=1;i--){
        for(int j=m;j>=1;j--){
            if(s[i][j] == 'o'){
                sumR[i][j] = sumR[i][j+1] + 1;
                sumD[i][j] = sumD[i+1][j] + 1;
            }
        }
    }
    ll ans = 0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(s[i][j] == 'o'){
                int cnt = sumL[i][j];
                if(j == m || s[i][j+1] != 'o'){
                    ans += dp2[cnt-1];
                    ans %= mod;
                    if(sum-cnt >= 0){
                        ans += (cnt/2)*1ll*pw[sum-cnt]%mod;
                        ans %= mod;
                    }
                }
                else{
                    ans += dp1[cnt-1];
                    ans %= mod;
                    if(sum-cnt-1 >= 0){
                        ans += (cnt/2)*1ll*pw[sum-cnt-1]%mod;
                        ans %= mod;
                    }
                }

                cnt = sumU[i][j];
                if(i == n || s[i+1][j] != 'o'){
                    ans += dp2[cnt-1];
                    ans %= mod;
                    if(sum-cnt >= 0){
                        ans += (cnt/2)*1ll*pw[sum-cnt]%mod;
                        ans %= mod;
                    }
                }
                else{
                    ans += dp1[cnt-1];
                    ans %= mod;
                    if(sum-cnt-1 >= 0){
                        ans += (cnt/2)*1ll*pw[sum-cnt-1]%mod;
                        ans %= mod;
                    }
                }
                ans %= mod;
            }
        }
    }
    printf("%lld\n", ans);
}