#include <bits/stdc++.h>
using namespace std;
const int N = 105, M = 105, K = 1005;
int n, m, cnt = 0;
char str[N][M];
long long mat[K][K], ans = 0ll, mod;
int trans(int x, int y) { return x * (m + 1) + y; }
long long qpow(long long a, long long k) {
  long long res = 1ll;
  while (k) {
    if (k & 1) res = res * a % mod;
    a = a * a % mod, k >>= 1;
  }
  return res;
}
long long det() {
  long long res = 1ll;
  for (int i = 1; i < cnt; i++) {
    int pos = i;
    for (int j = i + 1; j < cnt; j++) {
      if (mat[j][i]) pos = j;
    }
    if (!mat[pos][i]) return 0ll;
    if (pos != i) res = (mod - res) % mod;
    for (int j = i; j < cnt; j++) swap(mat[pos][j], mat[i][j]);
    res = res * mat[i][i] % mod;
    for (int j = i + 1; j < cnt; j++) {
      long long coef = mat[j][i] * qpow(mat[i][i], mod - 2) % mod;
      for (int k = i; k < cnt; k++)
        mat[j][k] = (mat[j][k] + mod * mod - coef * mat[i][k]) % mod;
    }
  }
  return res;
}
int fa[N * M], id[N * M];
int findroot(int u) { return fa[u] == u ? u : fa[u] = findroot(fa[u]); }
bool build_matrix(int r) {
  cnt = 0;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= m; j++) fa[trans(i, j)] = trans(i, j);
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if ((i + j) % 2 != r && str[i][j] == '/') {
        int x = findroot(trans(i + 1, j)), y = findroot(trans(i, j + 1));
        if (x == y) return false;
        fa[x] = y;
      }
      if ((i + j) % 2 == r && str[i][j] == '\\') {
        int x = findroot(trans(i, j)), y = findroot(trans(i + 1, j + 1));
        if (x == y) return false;
        fa[x] = y;
      }
    }
  }
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= m; j++) {
      if ((i + j) % 2 == r && fa[trans(i, j)] == trans(i, j))
        id[trans(i, j)] = cnt++;
    }
  }
  for (int i = 0; i < cnt; i++) {
    for (int j = 0; j < cnt; j++) mat[i][j] = 0ll;
  }
  int total = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (str[i][j] == '*') total++;
      if ((i + j) % 2 != r && str[i][j] == '*') {
        int x = id[findroot(trans(i + 1, j))],
            y = id[findroot(trans(i, j + 1))];
        if (x == y) continue;
        mat[x][x] = (mat[x][x] + 1ll) % mod,
        mat[y][y] = (mat[y][y] + 1ll) % mod;
        mat[x][y] = (mat[x][y] + mod - 1ll) % mod,
        mat[y][x] = (mat[y][x] + mod - 1ll) % mod;
      }
      if ((i + j) % 2 == r && str[i][j] == '*') {
        int x = id[findroot(trans(i, j))],
            y = id[findroot(trans(i + 1, j + 1))];
        if (x == y) continue;
        mat[x][x] = (mat[x][x] + 1ll) % mod,
        mat[y][y] = (mat[y][y] + 1ll) % mod;
        mat[x][y] = (mat[x][y] + mod - 1ll) % mod,
        mat[y][x] = (mat[y][x] + mod - 1ll) % mod;
      }
    }
  }
  return total >= cnt - 1;
}
int main() {
  scanf("%d%d%lld", &n, &m, &mod);
  for (int i = 0; i < n; i++) scanf("%s", str[i]);
  if (build_matrix(0)) ans = (ans + det()) % mod;
  if (build_matrix(1)) ans = (ans + det()) % mod;
  printf("%lld\n", ans);
  return 0;
}
