#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define all(x) (x).begin(), (x).end()
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
void debugF(ostream &os) {os << endl;}
template <typename Head, typename... Tail>
void debugF(ostream &os, Head H, Tail... T) { os << " " << H; debugF(os, T...); }
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debugF(cerr, __VA_ARGS__)
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); os << (i>0 ? " ":"") << v[i++]); return os;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int mod = 998244353;

ll expMod(ll a, ll b, ll mod){
    ll ans = 1;
    while(b){
        if(b&1) ans = (ans*a)%mod;
        a = (a*a)%mod;
        b >>= 1;
    }
    return ans;
}

int calc(vector<string> &M, vi &dp2){
    int n = M.size(); int m = M[0].size();
    int i,j;
    int ans = 0;
    for(i=0;i<n;i++){
        int cc = 0;
        for(j=0;j<m;j++){
            if(M[i][j] == 'o'){
                cc++;
                if(j+1 >= m || M[i][j+1] != 'o'){
                    ans += dp2[cc-1];
                    ans %= mod;
                }
            }
            else 
                cc = 0;
        }
    }
    return ans;
}

void transpose(vector<string> &M){
    int n = M.size(); int m = M[0].size();
    vector<string> M2(m, string(n,'.'));
    int i,j;
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            M2[j][i] = M[i][j];
        }
    }
    M = M2;
}

void solve(){
    int n, m, i, j;
    cin >> n >> m;
    vector<string> M(n);
    cin >> M;
    int nw = 0;
    for(i=0;i<n;i++){
        nw += count(all(M[i]), 'o');
    }
    if(nw < 2){
        cout << 0 << "\n";
        return;
    }

    int N = max(n,m);

    vi p2(nw+1);
    p2[0] = 1;
    for(i=1;i<=nw;i++){
        p2[i] = (p2[i-1]*2)%mod;
    }
    ll div4 = expMod(4, mod-2, mod);
    
    vi dp(N);
    vi dp2(N); //dp2[i] = dp[0] + ... + dp[i-1]
    dp[0] = p2[nw-2];
    dp2[0] = 0;
    for(i=1;i<N;i++){
        dp[i] = p2[nw-3];
        if(i-2 >= 0){
            dp[i] += (dp[i-2]*div4)%mod;
            dp[i] %= mod;  
        }
        dp2[i] = (dp2[i-1] + dp[i-1])%mod;
    }

    auto ans = calc(M, dp2);
    transpose(M);
    ans += calc(M, dp2);
    ans %= mod;
    cout << ans << "\n";
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int nt = 1;
    for(int tt=1;tt<=nt;tt++){
        solve();
    }
    return 0;
}