#include <bits/stdc++.h>
int MOD = int(1e9) + 7;
using namespace std;
const int N = 300;
char str[N][N + 1];
int id[N + 1][N + 1], P[(N + 1) * (N + 1)], D[2], id2[(N + 1) * (N + 1)];
long long M[2][2 * N + 1][2 * N + 1];
int t(int i, int j) { return (i ^ j) & 1; }
int find(int x) { return x == P[x] ? x : (P[x] = find(P[x])); }
bool join(int a, int b) {
  a = find(a);
  b = find(b);
  if (a == b) return false;
  P[a] = b;
  return true;
}
void f(int x, int y, int z) {
  x = id2[find(x)];
  y = id2[find(y)];
  if (x == y) return;
  M[z][x][x] = (M[z][x][x] + 1) % MOD;
  M[z][y][y] = (M[z][y][y] + 1) % MOD;
  M[z][x][y] = (M[z][x][y] + MOD - 1) % MOD;
  M[z][y][x] = (M[z][y][x] + MOD - 1) % MOD;
}
long long inv(long long x, long long y, long long p, long long q, long long r,
              long long s) {
  if (y == 0) return (p % MOD + MOD) % MOD;
  return inv(y, x % y, r, s, p - r * (x / y), q - s * (x / y));
}
long long det(long long F[2 * N + 1][2 * N + 1], int D) {
  long long ans = 1;
  for (int i = 0; i < D; i++) {
    int r = i;
    while (r < D && F[r][i] == 0) ++r;
    if (r >= D) return 0;
    if (r != i) ans = ans * (MOD - 1) % MOD;
    for (int j = i; j < D; j++) swap(F[r][j], F[i][j]);
    ans = ans * F[i][i] % MOD;
    long long t = inv(F[i][i], MOD, 1, 0, 0, 1);
    for (int j = i; j < D; j++) F[i][j] = (F[i][j] * t) % MOD;
    for (int r = i + 1; r < D; r++)
      if (F[r][i] != 0) {
        long long s = F[r][i];
        for (int j = i; j < D; j++) {
          F[r][j] = (F[r][j] - s * F[i][j]) % MOD;
          if (F[r][j] < 0) F[r][j] += MOD;
        }
      }
  }
  return ans;
}
bool solve(int testNumber) {
  int n, m;
  if (scanf("%d %d %d", &n, &m, &MOD) == EOF) return false;
  for (int i = 0; i < n; i++) scanf("%s", str[i]);
  int x = 0;
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= m; j++) {
      P[x] = x;
      id[i][j] = x++;
    }
  bool valid = true;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      if (str[i][j] != '*') {
        int a, b;
        if (str[i][j] == '/') {
          a = id[i][j + 1];
          b = id[i + 1][j];
        } else {
          a = id[i][j];
          b = id[i + 1][j + 1];
        }
        valid &= join(a, b);
      }
  if (!valid) {
    puts("0");
    return true;
  }
  for (int i = 0; i < 2; i++)
    for (int j = 0; j <= 2 * N; j++)
      for (int k = 0; k <= 2 * N; k++) M[i][j][k] = 0;
  D[0] = D[1] = 0;
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= m; j++)
      if (id[i][j] == find(id[i][j])) id2[id[i][j]] = D[t(i, j)]++;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      if (str[i][j] == '*') {
        f(id[i][j], id[i + 1][j + 1], t(i, j));
        f(id[i + 1][j], id[i][j + 1], t(i + 1, j));
      }
  long long ret = (det(M[0], D[0] - 1) + det(M[1], D[1] - 1)) % MOD;
  printf("%lld\n", ret);
  return true;
}
int main() {
  for (int i = 1; solve(i); i++)
    ;
  return 0;
}
