#include <bits/stdc++.h>
const int maxn = 205;
const int maxk = 805;
const int maxm = 205;
int n, m, ind;
int fa[maxn * maxm], id[maxn * maxm];
long long ans, mod, A[maxk][maxk], D[maxk][maxk];
char map[maxn][maxm];
inline int getFa(int x) { return x == fa[x] ? x : fa[x] = getFa(fa[x]); }
inline int getID(int i, int j) { return (i - 1) * m + j; }
inline void merge(int u, int v) {
  u = getFa(u), v = getFa(v);
  if (u != v)
    fa[u] = v;
  else
    puts("0"), exit(0);
}
long long fsp(long long a, long long b) {
  a %= mod;
  long long res = 1;
  while (b) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod, b >>= 1;
  }
  return res;
}
long long Gauss() {
  long long sig = 1;
  for (int i = 1; i < ind; ++i) {
    if (!D[i][i]) {
      bool flag = 0;
      for (int j = i + 1; j < ind; ++j)
        if (D[j][i]) {
          std::swap(D[j], D[i]), flag = 1, sig *= -1;
          break;
        }
      if (!flag) return 0;
    }
    for (int j = i + 1; j < ind; ++j) {
      long long tmp = D[j][i] * fsp(D[i][i], mod - 2) % mod;
      for (int k = i; k < ind; ++k) D[j][k] = (D[j][k] - D[i][k] * tmp) % mod;
    }
  }
  long long res = 1;
  for (int i = 1; i < ind; ++i) (res *= D[i][i]) %= mod;
  return res * sig;
}
int main() {
  scanf("%d%d%lld\n", &n, &m, &mod);
  ++n, ++m;
  for (int i = 1; i <= n * m; ++i) fa[i] = i;
  for (int i = 1; i < n; ++i) {
    scanf("%s", map[i] + 1);
    for (int j = 1; j < m; ++j) {
      if (map[i][j] == '\\') merge(getID(i, j), getID(i + 1, j + 1));
      if (map[i][j] == '/') merge(getID(i, j + 1), getID(i + 1, j));
    }
  }
  ind = 0;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j)
      if (!((i + j) & 1) && getFa(getID(i, j)) == getID(i, j))
        id[getID(i, j)] = ++ind;
  for (int i = 1; i < n; ++i) {
    for (int j = 1; j < m; ++j) {
      if (map[i][j] != '*') continue;
      int u = getID(i, j + ((i + j) & 1)),
          v = getID(i + 1, j + 1 - ((i + j) & 1));
      u = getFa(u), v = getFa(v);
      if (u != v)
        ++A[id[u]][id[v]], ++A[id[v]][id[u]], ++D[id[u]][id[u]],
            ++D[id[v]][id[v]];
    }
  }
  for (int i = 1; i <= ind; ++i)
    for (int j = 1; j <= ind; ++j) (D[i][j] -= A[i][j]) %= mod;
  ans += Gauss();
  ind = 0;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j)
      if (((i + j) & 1) && getFa(getID(i, j)) == getID(i, j))
        id[getID(i, j)] = ++ind;
  for (int i = 1; i <= ind; ++i)
    for (int j = 1; j <= ind; ++j) A[i][j] = D[i][j] = 0;
  for (int i = 1; i < n; ++i) {
    for (int j = 1; j < m; ++j) {
      if (map[i][j] != '*') continue;
      int u = getID(i + 1, j + ((i + j) & 1)),
          v = getID(i, j + 1 - ((i + j) & 1));
      u = getFa(u), v = getFa(v);
      if (u != v)
        ++A[id[u]][id[v]], ++A[id[v]][id[u]], ++D[id[u]][id[u]],
            ++D[id[v]][id[v]];
    }
  }
  for (int i = 1; i <= ind; ++i)
    for (int j = 1; j <= ind; ++j) (D[i][j] -= A[i][j]) %= mod;
  ans += Gauss();
  printf("%lld", (ans % mod + mod) % mod);
}
