cin >> n >> m; int sum = 0; for (int i = 1; i <= n; ++i) { cin >> s + 1; A[i].resize(m + 1); for (int j = 1; j <= m; ++j) A[i][j] = s[j] == 'o', sum += A[i][j]; } ll inv2 = pow_mod(2, p - 2), inv4 = inv2 * inv2 % p; f[1] = 0; f[2] = inv4; for (int i = 3; i <= max(n, m); ++i) f[i] = (inv2 * f[i - 1] % p + inv2 * f[i - 2] + inv4) % p; for (int i = 1; i <= n; ++i) for (int j = 1; j <= m; ++j) { if (!A[i][j]) continue; int k = j; while (k <= m && A[i][k]) ++k; ans = (ans + f[k - j]) % p; j = k - 1; } for (int j = 1; j <= m; ++j) for (int i = 1; i <= n; ++i) { if (!A[i][j]) continue; int k = i; while (k <= n && A[k][j]) ++k; ans = (ans + f[k - i]) % p; i = k - 1; } cout << ans * pow_mod(2, sum) % p << "\n"; return0; }