#include <bits/stdc++.h>
using namespace std;
#define pii pair<int, int>
#define x first
#define y second
using ll = long long;
const ll maxn = 3e5 + 1, mod = 998244353;
ll dp2[maxn][2], cnt[maxn], pow2[maxn], dp[maxn], cnt0[maxn][2], cnt2[maxn][2];
vector<bool> a[maxn], b[maxn];

signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    int n, m;
    cin >> n >> m;
    int w = 0;
    for (int i = 0; i < n; ++i) {
        a[i].resize(m);
        for (int j = 0; j < m; ++j) {
            char c;
            cin >> c;
            if (c == '*') {
                a[i][j] = false;
            }
            else {
                ++w;
                a[i][j] = true;
            }
        }
    }
    dp[1] = 1;
    dp2[1][1] = 1;
    cnt[1] = 1;
    pow2[0] = 1;
    pow2[1] = 2;
    cnt0[0][0] = 1;
    cnt0[0][1] = 1;
    cnt2[1][1] = 1;
    for (int i = 1; i < maxn; ++i) {
        cnt0[i][0] = (cnt0[i - 1][0] + cnt0[i - 1][1]) % mod;
        cnt0[i][1] = cnt0[i - 1][0];
    }
    for (int i = 2; i < maxn; ++i) {
        dp2[i][0] = (dp[i - 1]) % mod;
        dp2[i][1] = (dp2[i - 1][0] + dp[i - 2] + cnt[i - 2] + (cnt0[i - 2][0] + cnt0[i - 2][1]) % mod) % mod;
        dp[i] = (dp2[i][0] + dp2[i][1]) % mod;
        cnt2[i][0] = cnt[i - 1];
        cnt2[i][1] = (cnt2[i - 1][0] + cnt[i - 2] + (cnt0[i - 2][0] + cnt0[i - 2][1]) % mod) % mod;
        cnt[i] = (cnt2[i][0] + cnt2[i][1]) % mod;
        pow2[i] = (pow2[i - 1] * 2) % mod;
    }
    ll ans = 0;
    for (int i = 0; i < n; ++i) {
        int j = 0;
        while (j < m && !a[i][j]) ++j;
        while (j < m) {
            int l = j;
            int r = j;
            while (r < m && a[i][r]) ++r;
            assert(w - (r - l) >= 0 && r - l - 1 >= 0);
            ans = (ans + (pow2[w - (r - l)] * dp[r - l - 1]) % mod) % mod;
            j = r;
            while (j < m && !a[i][j]) ++j;
        }
    }
    for (int i = 0; i < m; ++i) {
        b[i].resize(n);
        for (int j = 0; j < n; ++j) b[i][j] = a[j][i];
    }
    swap(n, m);
    for (int i = 0; i < n; ++i) {
        int j = 0;
        while (j < m && !b[i][j]) ++j;
        while (j < m) {
            int l = j;
            int r = j;
            while (r < m && b[i][r]) ++r;
            assert(w - (r - l) >= 0 && r - l - 1 >= 0);
            ans = (ans + (pow2[w - (r - l)] * dp[r - l - 1]) % mod) % mod;
            j = r;
            while (j < m && !b[i][j]) ++j;
        }
    }
    cout << ans;
}