#include <bits/stdc++.h>
using namespace std;
const long long N = 1000, K = 1005;
long long a[K][K], b[N * N], c[N * N][2], f[N * N], id[N * N];
char ch[N];
bool bw[N * N];
long long n, m, mod, nm, cnt;
long long pos(long long x, long long y) { return (x - 1) * (m + 1) + y; }
long long find(long long x) { return f[x] == x ? x : f[x] = find(f[x]); }
long long pow(long long x, long long y) {
  long long res = 1;
  while (y) {
    if (y & 1) (res *= x) %= mod;
    x = (x * x) % mod;
    y >>= 1;
  }
  return res;
}
long long Det() {
  for (long long i = 1; i <= cnt; i++) {
    for (long long j = 1; j <= cnt; j++) {
      (a[i][j] += mod) %= mod;
    }
  }
  long long ans = 1;
  for (long long i = 1; i <= cnt; i++) {
    long long tmp = i;
    for (long long j = i + 1; j <= cnt; j++)
      if (a[tmp][i] < a[j][i]) tmp = j;
    if (tmp != i) {
      for (long long j = i; j <= cnt; j++) swap(a[i][j], a[tmp][j]);
      ans = (mod - ans) % mod;
    }
    ans = (ans * a[i][i]) % mod;
    for (long long j = i + 1; j <= cnt; j++) {
      long long tmp = a[j][i] * pow(a[i][i], mod - 2) % mod;
      for (long long k = i + 1; k <= cnt; k++)
        a[j][k] = (a[j][k] - a[i][k] * tmp % mod + mod) % mod;
    }
  }
  return ans % mod;
}
signed main() {
  scanf("%lld%lld%lld", &n, &m, &mod);
  nm = (n + 1) * (m + 1);
  for (long long i = 1; i <= nm; i++) f[i] = i;
  for (long long i = 1; i <= n; i++) {
    scanf("%s", ch + 1);
    for (long long j = 1, x, y; j <= m; j++) {
      if (ch[j] == '*') {
        c[pos(i, j)][0] = c[pos(i, j + 1)][1] = 1;
        continue;
      } else if (ch[j] == '/')
        x = find(pos(i, j + 1)), y = find(pos(i + 1, j));
      else
        x = find(pos(i, j)), y = find(pos(i + 1, j + 1));
      if (x == y) {
        puts("0");
        return 0;
      }
      f[x] = y;
    }
  }
  for (long long i = 1; i <= n + 1; i++) {
    bw[pos(i, 1)] = bw[pos(i - 1, 1)] ^ 1;
    for (long long j = 2; j <= m + 1; j++)
      bw[pos(i, j)] = bw[pos(i, j - 1)] ^ 1;
  }
  long long y[5], k, ans = 0, x;
  for (long long col = 0; col <= 1; col++) {
    memset(a, 0, sizeof(a));
    memset(id, 0, sizeof(id));
    cnt = 0;
    for (long long i = 1; i <= nm; i++)
      if (bw[i] == col && f[i] == i) id[i] = ++cnt;
    for (long long i = 1; i <= nm; i++)
      if (bw[i] == col) {
        x = id[find(i)];
        k = 0;
        if (c[i][1]) y[++k] = id[find(i + m)];
        if (c[i][0]) y[++k] = id[find(i + m + 2)];
        for (long long j = 1; j <= k; j++)
          a[x][x]++, a[y[j]][y[j]]++, a[x][y[j]]--, a[y[j]][x]--;
      }
    cnt--;
    (ans += Det()) %= mod;
  }
  printf("%lld", ans);
  return 0;
}
