#include <bits/stdc++.h>
template <typename T>
inline bool MIN(T &a, const T &b) {
  return a > b ? a = b, 1 : 0;
}
template <typename T>
inline bool MAX(T &a, const T &b) {
  return a < b ? a = b, 1 : 0;
}
int mod;
inline int plu(int a, int b) { return a + b >= mod ? a + b - mod : a + b; }
inline int sub(int a, int b) { return a - b < 0 ? a - b + mod : a - b; }
inline int mul(int a, int b) { return (long long)a * b % mod; }
inline int inc(int &a, int b) { a = plu(a, b); }
using namespace std;
int n, m;
char A[110][110];
int idx(int i, int j) { return j + 1 + i * (m + 1); }
int dad[110 * 110], bel[110 * 110];
int gr(int x) { return x == dad[x] ? x : dad[x] = gr(dad[x]); }
int exgcd(int a, int b, int &x, int &y) {
  if (!b) {
    x = 1;
    y = 0;
    return a;
  }
  int res = exgcd(b, a % b, x, y);
  int t = x;
  x = y;
  y = t - a / b * y;
  return res;
}
int get_inv(int v) {
  int x, y;
  exgcd(v, mod, x, y);
  return (x % mod + mod) % mod;
}
int halt() {
  printf("0\n");
  exit(0);
}
vector<int> q;
int M[450][450];
int solve(int n, int A[][450]) {
  int res = 1;
  for (int i = 1; i < n; ++i)
    for (int j = 1; j < n; ++j) {
      A[i][j] = (A[i][j] % mod + mod) % mod;
    }
  for (int i = 1; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      while (A[j][i]) {
        int t = A[i][i] / A[j][i];
        for (int k = i; k < n; ++k) inc(A[i][k], mul(mod - 1, mul(A[j][k], t)));
        for (int k = i; k < n; ++k) swap(A[i][k], A[j][k]);
        res = mul(res, mod - 1);
      }
    }
  }
  for (int i = 1; i < n; ++i) res = (long long)res * A[i][i] % mod;
  return res;
}
int calc(int fg) {
  memset(M, 0, sizeof(M));
  for (int i = 1; i < 110 * 110; ++i) dad[i] = i;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j)
      if (A[i][j] != '*') {
        if (A[i][j] == '/') {
          int a = idx(i - 1, j), b = idx(i, j - 1);
          if (fg != (i - 1 + j & 1)) continue;
          a = gr(a), b = gr(b);
          if (a == b) halt();
          dad[a] = b;
        } else {
          int a = idx(i, j), b = idx(i - 1, j - 1);
          if (fg != (i + j & 1)) continue;
          a = gr(a), b = gr(b);
          if (a == b) halt();
          dad[a] = b;
        }
      }
  }
  q.clear();
  for (int i = 0; i <= n; ++i)
    for (int j = 0; j <= m; ++j)
      if ((i + j & 1) == fg) {
        if (dad[idx(i, j)] != idx(i, j)) continue;
        q.push_back(idx(i, j));
        bel[idx(i, j)] = q.size();
      }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j)
      if (A[i][j] == '*') {
        int a = idx(i - 1, j), b = idx(i, j - 1);
        if (fg == (i - 1 + j & 1)) {
          a = bel[gr(a)], b = bel[gr(b)];
          ++M[a][a], ++M[b][b];
          --M[a][b], --M[b][a];
        }
        a = idx(i, j), b = idx(i - 1, j - 1);
        if (fg == (i + j & 1)) {
          a = bel[gr(a)], b = bel[gr(b)];
          ++M[a][a], ++M[b][b];
          --M[a][b], --M[b][a];
        }
      }
  }
  return solve(q.size(), M);
}
int main() {
  scanf("%d%d%d", &n, &m, &mod);
  for (int i = 1; i <= n; ++i) scanf("%s", A[i] + 1);
  printf("%d\n", plu(calc(0), calc(1)));
  return 0;
}
