#include <bits/stdc++.h>
using namespace std;
int n, m, mod, fa[11005];
int bel[11005], tot = 0;
int x[10005], y[10005];
int t[405][405];
char s[105][105];
inline int get(int a, int b) { return (a - 1) * (m + 1) + b; }
inline int getf(int a) {
  if (fa[a] == a) return a;
  return fa[a] = getf(fa[a]);
}
inline void merge(int a, int b) { fa[getf(a)] = getf(b); }
inline int qpow(int a, int b) {
  int res = 1, tp = a;
  while (b) {
    if (b & 1) res = 1ll * res * tp % mod;
    tp = 1ll * tp * tp % mod;
    b >>= 1;
  }
  return res;
}
inline int det(int n) {
  int i, j, k, ans = 1, sgn = 0;
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= n; j++) {
      t[i][j] %= mod;
      if (t[i][j] < 0) t[i][j] += mod;
    }
  }
  for (i = 1; i <= n; i++) {
    if (t[i][i] == 0) {
      for (j = i + 1; j <= n; j++) {
        if (t[j][i] != 0) {
          swap(t[i], t[j]);
          break;
        }
      }
      sgn ^= 1;
    }
    for (j = i + 1; j <= n; j++) {
      int p = mod - (1ll * t[j][i] * qpow(t[i][i], mod - 2) % mod);
      for (k = i; k <= n; k++) {
        t[j][k] += 1ll * p * t[i][k] % mod;
        if (t[j][k] >= mod) t[j][k] -= mod;
      }
    }
  }
  for (i = 1; i <= n; i++) ans = 1ll * ans * t[i][i] % mod;
  if (sgn) ans = mod - ans;
  return ans;
}
int main() {
  int i, j, num = 0, ans = 0;
  scanf("%d%d%d", &n, &m, &mod);
  for (i = 1; i <= (n + 1) * (m + 1); i++) fa[i] = i;
  for (i = 1; i <= n; i++) {
    scanf("%s", s[i] + 1);
    for (j = 1; j <= m; j++) {
      if (s[i][j] == '/') {
        merge(get(i, j + 1), get(i + 1, j));
      }
      if (s[i][j] == '\\') {
        merge(get(i, j), get(i + 1, j + 1));
      }
      if (s[i][j] == '*') {
        x[++num] = i;
        y[num] = j;
      }
    }
  }
  tot = 0;
  for (i = 1; i <= n + 1; i++) {
    for (j = ((i & 1) ? 1 : 2); j <= m + 1; j += 2) {
      int p = getf(get(i, j));
      if (!bel[p]) bel[p] = ++tot;
    }
  }
  for (i = 1; i <= num; i++) {
    int a, b;
    if ((x[i] & 1) == (y[i] & 1))
      a = get(x[i], y[i]), b = get(x[i] + 1, y[i] + 1);
    else
      a = get(x[i], y[i] + 1), b = get(x[i] + 1, y[i]);
    a = bel[getf(a)];
    b = bel[getf(b)];
    t[a][b]--;
    t[b][a]--;
    t[a][a]++;
    t[b][b]++;
  }
  ans += det(tot - 1);
  tot = 0;
  memset(bel, 0, sizeof(bel));
  memset(t, 0, sizeof(t));
  for (i = 1; i <= n + 1; i++) {
    for (j = ((i & 1) ? 2 : 1); j <= m + 1; j += 2) {
      int p = getf(get(i, j));
      if (!bel[p]) bel[p] = ++tot;
    }
  }
  for (i = 1; i <= num; i++) {
    int a, b;
    if ((x[i] & 1) != (y[i] & 1))
      a = get(x[i], y[i]), b = get(x[i] + 1, y[i] + 1);
    else
      a = get(x[i], y[i] + 1), b = get(x[i] + 1, y[i]);
    a = bel[getf(a)];
    b = bel[getf(b)];
    t[a][b]--;
    t[b][a]--;
    t[a][a]++;
    t[b][b]++;
  }
  ans += det(tot - 1);
  while (ans >= mod) ans -= mod;
  printf("%d\n", ans);
  return 0;
}
