#include <bits/stdc++.h>
char originG[100][100 + 1];
std::vector<int> rG[((100 + 1) * (100 + 1)) / 2 + 1],
    bG[((100 + 1) * (100 + 1)) / 2 + 1],
    broken_rG[((100 + 1) * (100 + 1)) / 2 + 1],
    broken_bG[((100 + 1) * (100 + 1)) / 2 + 1];
std::vector<int> contracted_G[100 * 100 / 2];
long long L_matrix[2 * 200 + 1][2 * 200 + 1];
int p[((100 + 1) * (100 + 1)) / 2 + 1 + 2 * 200 + 1];
int root(int x) {
  if (p[x] == x) return x;
  return p[x] = root(p[x]);
}
bool isRed(int row, int col) { return !((row & 1) ^ (col & 1)); }
int getIdx(int row, int col, int m) {
  int idx = row / 2 * (m + 1);
  row %= 2;
  idx += (row * (m + 1) + col) / 2;
  return idx;
}
void makeEdge(std::vector<int> *tmpG, int a, int b) {
  tmpG[a].push_back(b);
  tmpG[b].push_back(a);
  return;
}
void makeGraph(int n, int m) {
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (originG[i][j] == '\\') {
        int a = getIdx(i, j, m), b = getIdx(i + 1, j + 1, m);
        std::vector<int> *tmpG;
        if (isRed(i, j))
          tmpG = rG;
        else
          tmpG = bG;
        makeEdge(tmpG, a, b);
      } else if (originG[i][j] == '/') {
        int a = getIdx(i, j + 1, m), b = getIdx(i + 1, j, m);
        std::vector<int> *tmpG;
        if (isRed(i, j + 1))
          tmpG = rG;
        else
          tmpG = bG;
        makeEdge(tmpG, a, b);
      } else {
        int a = getIdx(i, j, m), b = getIdx(i + 1, j + 1, m);
        int c = getIdx(i, j + 1, m), d = getIdx(i + 1, j, m);
        std::vector<int> *tmpG1, *tmpG2;
        if (isRed(i, j)) {
          tmpG1 = broken_rG;
          tmpG2 = broken_bG;
        } else {
          tmpG1 = broken_bG;
          tmpG2 = broken_rG;
        }
        makeEdge(tmpG1, a, b);
        makeEdge(tmpG2, c, d);
      }
    }
  }
  return;
}
long long MOD(long long x, int mod) {
  x %= mod;
  if (x < 0) x += mod;
  return x;
}
int determinant(int n, int mod) {
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) L_matrix[i][j] %= mod;
  long long ans = 1;
  for (int row1 = 0; row1 < n; row1++) {
    if (L_matrix[row1][row1] == 0) {
      for (int row2 = row1 + 1; row2 < n; row2++) {
        if (L_matrix[row2][row1] == 0) continue;
        for (int i = 0; i < n; i++)
          std::swap(L_matrix[row1][i], L_matrix[row2][i]);
        ans *= -1;
        break;
      }
      if (L_matrix[row1][row1] == 0) return 0;
    }
    for (int row2 = row1 + 1; row2 < n; row2++) {
      long long row2_head = L_matrix[row2][row1];
      if (row2_head == 0) continue;
      long long a = L_matrix[row1][row1], b = L_matrix[row2][row1];
      std::pair<int, int> pa(1, 0), pb(0, 1);
      while (b != 0) {
        long long tmp = a / b;
        pa.first = (pa.first - pb.first * tmp) % mod;
        pa.second = (pa.second - pb.second * tmp) % mod;
        a = a - b * tmp;
        std::swap(a, b);
        std::swap(pa, pb);
        ans *= -1;
      }
      for (int i = row1; i < n; i++) {
        a = L_matrix[row1][i], b = L_matrix[row2][i];
        L_matrix[row1][i] =
            ((pa.first * a) % mod + (pa.second * b) % mod) % mod;
        L_matrix[row2][i] =
            ((pb.first * a) % mod + (pb.second * b) % mod) % mod;
      }
    }
  }
  for (int i = 0; i < n; i++) ans = ans * L_matrix[i][i] % mod;
  return MOD(ans, mod);
}
int getAns(std::vector<int> *G, std::vector<int> *broken_G, int np, int mod) {
  for (int i = 0; i < np; i++) p[i] = i;
  for (int i = 0; i < np; i++) {
    for (unsigned j = 0; j < G[i].size(); j++) {
      int now = G[i][j];
      if (now < i) continue;
      if (root(i) != root(now))
        p[root(now)] = root(i);
      else
        return 0;
    }
  }
  int contracted_np = 0;
  for (int i = 0; i < np; i++) {
    if (p[i] == i) {
      p[i] = p[np + contracted_np] = np + contracted_np;
      contracted_np++;
    }
  }
  memset(L_matrix, 0, sizeof L_matrix);
  for (int i = 0; i < np; i++) {
    for (unsigned j = 0; j < broken_G[i].size(); j++) {
      int now = broken_G[i][j];
      if (now < i) continue;
      if (root(now) == root(i)) continue;
      int a = root(i) - np, b = root(now) - np;
      L_matrix[a][b]--;
      L_matrix[b][a]--;
      L_matrix[a][a]++;
      L_matrix[b][b]++;
    }
  }
  int ans = determinant(contracted_np - 1, mod);
  return ans;
}
int main() {
  int n, m, mod;
  scanf("%d%d%d", &n, &m, &mod);
  getchar();
  for (int i = 0; i < n; i++) {
    fgets(originG[i], m + 2, stdin);
    originG[i][m] = '\0';
  }
  int np = (n + 1) * (m + 1);
  int nrp = (np % 2) ? np / 2 + 1 : np / 2, nbp = np - nrp;
  makeGraph(n, m);
  int ans =
      (getAns(rG, broken_rG, nrp, mod) + getAns(bG, broken_bG, nbp, mod)) % mod;
  printf("%d\n", ans);
  return 0;
}
