#include <bits/stdc++.h>
int md;
int ksm(int a, int b) {
  int jg = 1;
  while (b > 0) {
    if (b & 1) jg = 1ll * jg * a % md;
    a = 1ll * a * a % md;
    b = (b >> 1);
  }
  return jg;
}
int gauss(int sz[202][202], int n) {
  int jg = 1;
  for (int i = 1; i <= n; i++) {
    int wz = -1;
    for (int j = i; j <= n; j++) {
      if (sz[j][i] != 0) {
        wz = j;
        break;
      }
    }
    if (wz == -1) continue;
    if (wz != i) {
      for (int j = 1; j <= n; j++) {
        int t = sz[i][j];
        sz[i][j] = sz[wz][j];
        sz[wz][j] = t;
      }
      jg = md - jg;
    }
    int ny = ksm(sz[i][i], md - 2);
    for (int j = i + 1; j <= n; j++) {
      int t = 1ll * sz[j][i] * ny % md;
      for (int k = 1; k <= n; k++)
        sz[j][k] = (sz[j][k] - 1ll * sz[i][k] * t % md + md) % md;
    }
  }
  for (int i = 1; i <= n; i++) jg = 1ll * jg * sz[i][i] % md;
  return jg;
}
int fa[50010];
int getv(int x) {
  if (x == fa[x]) return x;
  return fa[x] = getv(fa[x]);
}
bool merge(int x, int y) {
  x = getv(x);
  y = getv(y);
  if (x == y) return false;
  fa[x] = y;
  return true;
}
int ls[50010], jz[202][202];
void addb(int a, int b) {
  jz[a][a] = (jz[a][a] + 1) % md;
  jz[b][b] = (jz[b][b] + 1) % md;
  jz[a][b] = (jz[a][b] - 1 + md) % md;
  jz[b][a] = (jz[b][a] - 1 + md) % md;
}
int scsjs(int n, int m, int A[50010], int B[50010], int C[50010], int D[50010],
          int s) {
  for (int i = 1; i <= n; i++) fa[i] = i, ls[i] = 0;
  for (int i = 0; i < m; i++) {
    if (!merge(A[i], B[i])) return 0;
  }
  int k = 0;
  for (int i = 1; i <= n; i++) {
    if (i == getv(i)) ls[i] = ++k;
  }
  for (int i = 1; i <= n; i++) ls[i] = ls[getv(i)];
  for (int i = 1; i <= k; i++) {
    for (int j = 1; j <= k; j++) jz[i][j] = 0;
  }
  for (int i = 0; i < s; i++) addb(ls[C[i]], ls[D[i]]);
  return gauss(jz, k - 1);
}
int sz[202][202], bh[202][202];
char zf[202];
int dd[300];
int A[50010], B[50010], C[50010], D[50010];
int main() {
  dd['*'] = 0;
  dd['/'] = 1;
  dd['\\'] = 2;
  int n, m, ans = 0;
  scanf("%d%d%d", &n, &m, &md);
  for (int i = 1; i <= n; i++) {
    scanf("%s", zf);
    for (int j = 1; j <= m; j++) sz[i][j] = dd[zf[j - 1]];
  }
  for (int s = 0; s < 2; s++) {
    int k = 0;
    for (int i = 1; i <= n + 1; i++) {
      for (int j = 1; j <= m + 1; j++) {
        if ((i + j) % 2 == s)
          bh[i][j] = ++k;
        else
          bh[i][j] = 0;
      }
    }
    int s1 = 0, s2 = 0;
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) {
        if (sz[i][j] == 1) {
          if (bh[i + 1][j]) {
            A[s1] = bh[i + 1][j];
            B[s1++] = bh[i][j + 1];
          }
        } else if (sz[i][j] == 2) {
          if (bh[i][j]) {
            A[s1] = bh[i][j];
            B[s1++] = bh[i + 1][j + 1];
          }
        } else {
          if (bh[i][j]) {
            C[s2] = bh[i][j];
            D[s2++] = bh[i + 1][j + 1];
          } else {
            C[s2] = bh[i + 1][j];
            D[s2++] = bh[i][j + 1];
          }
        }
      }
    }
    ans = (ans + scsjs(k, s1, A, B, C, D, s2)) % md;
  }
  printf("%d", ans);
  return 0;
}
