#include <bits/stdc++.h>

#define ed end()
#define bg begin()
#define mp make_pair
#define pb push_back
#define all(x) x.bg,x.ed
#define newline puts("")
#define si(x) ((int)x.size())
#define rep(i,n) for(int i=1;i<=n;++i)
#define rrep(i,n) for(int i=0;i<n;++i)
#define srep(i,s,t) for(int i=s;i<=t;++i)
#define drep(i,s,t) for(int i=t;i>=s;--i)

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int Maxn = 3e5+10;
const int Inf = 0x7f7f7f7f;
const ll Inf_ll = 1ll*Inf*Inf;
const int Mod = 998244353;
const double eps = 1e-7;

#define DEBUG
#define d1(x) std::cout << #x " = " << (x) << std::endl
#define d2(x, y) std::cout << #x " = " << (x) << " ," #y " = " << (y) << std::endl
#define disp(arry, fr, to) \
    { \
        std::cout << #arry " : "; \
        for(int _i = fr; _i <= to; _i++) std::cout << arry[_i] << " "; \
        std::cout << std::endl; \
    }


int n, m;
int *a[Maxn];
char s[Maxn];

ll mypow(ll a,ll b){
    ll inv = 1;
    while( b > 0 ){
        if( b&1 )  inv = inv*a%Mod;
        a = a*a%Mod;
        b >>= 1;
    }
    return inv;
}

ll inv[Maxn],fac[Maxn],finv[Maxn];
void Init(int n){
    inv[0] = inv[1] = fac[0] = finv[0] = 1;
    for(int i=2;i<=n;i++)
        inv[i] = 1ll*(Mod - Mod/i)*inv[Mod%i]%Mod;
    for(int i=1;i<=n;i++)
        fac[i] = fac[i-1]*i%Mod,
        finv[i] = finv[i-1]*inv[i]%Mod;
}

ll C(int n, int m){
    return fac[n]*finv[m]%Mod*finv[n-m]%Mod;
}

int main(){
    scanf("%d %d",&n,&m);
    for(int i=1;i<=n;i++)  a[i] = new int[m+10];
    int Sum = 0;
    for(int i=1;i<=n;i++)
    {
        scanf("%s",s+1);
        for(int j=1;j<=m;j++)  a[i][j] = (s[j] == 'o'), Sum += a[i][j];
    }
    ll ans = 0;
    // cout<<233<<endl;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            if( a[i][j] != 1 )  continue;
            int k = j, cnt = 1;
            while( k+1 <= m && a[i][k+1] == a[i][j] )  k++, cnt++;
            j = k;
            ans = (ans + 1ll*(cnt/2)*mypow(2, Sum-cnt))%Mod;
            for(int kk=3;kk<=cnt;kk++)
                ans = (ans + 2ll*((kk-1)/2)*mypow(2, Sum-kk))%Mod;
            for(int kk=4;kk<=cnt;kk++)
                ans = (ans + 1ll*((kk-2)/2)*mypow(2, Sum-kk)%Mod*(cnt-kk+1))%Mod;
        }
    }
    // d1(ans);    
    for(int j=1;j<=m;j++)
    {
        for(int i=1;i<=n;i++)
        {
            if( a[i][j] != 1 )  continue;
            int k = i, cnt = 1;
            while( k+1 <= n && a[k+1][j] == a[i][j] )  k++, cnt++;
            i = k;
            ans = (ans + 1ll*(cnt/2)*mypow(2, Sum-cnt))%Mod;
            for(int kk=3;kk<=cnt;kk++)
                ans = (ans + 2ll*((kk-1)/2)*mypow(2, Sum-kk))%Mod;
            for(int kk=4;kk<=cnt;kk++)
                ans = (ans + 1ll*((kk-2)/2)*mypow(2, Sum-kk)%Mod*(cnt-kk+1))%Mod;
        }
    }
    printf("%lld\n", ans);
    return 0;
}