#include <bits/stdc++.h>
using namespace std;
long long n, m, mod, cnt;
long long fa[640010], col[640010], bel[640010], id[810][810], num[810],
    mt[3][810][810];
char c[810][810];
long long find(long long x) {
  if (fa[x] ^ x) return fa[x] = find(fa[x]);
  return x;
}
long long read() {
  long long r = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c <= '9' && c >= '0') r = (r << 1) + (r << 3) + c - '0', c = getchar();
  return r * f;
}
void put(long long x) {
  if (x < 0) {
    putchar('-');
    x = ~x + 1;
  }
  if (x > 9) put(x / 10);
  putchar(x % 10 + '0');
}
long long poww(long long x, long long y) {
  long long s = 1;
  while (y) {
    if (y & 1) s = s * x % mod;
    x = x * x % mod, y >>= 1;
  }
  return s;
}
long long det(long long nn, long long a[810][810]) {
  long long sum = 1;
  nn--;
  for (long long i = 1; i <= nn; i++) {
    long long maxx = i;
    for (long long j = i + 1; j <= nn; j++)
      if (a[j][i] > a[maxx][i]) maxx = j;
    if (maxx ^ i) sum = mod - sum;
    for (long long j = 1; j <= nn; j++) swap(a[i][j], a[maxx][j]);
    if (!a[i][i]) return 0;
    long long qwe = a[i][i];
    sum = sum * qwe % mod;
    for (long long j = i + 1; j <= nn; j++) {
      if (j == i) continue;
      qwe = a[j][i] * poww(a[i][i], mod - 2) % mod;
      for (long long k = i; k <= nn; k++)
        a[j][k] = (a[j][k] - a[i][k] * qwe % mod + mod) % mod;
    }
  }
  return sum;
}
signed main() {
  n = read(), m = read(), mod = read();
  scanf("\n");
  for (long long i = 1; i <= n + 1; i++)
    for (long long j = 1; j <= m + 1; j++)
      id[i][j] = ++cnt, fa[cnt] = cnt, col[cnt] = (i + j) & 1;
  for (long long i = 1; i <= n; i++) {
    scanf("%s", c[i] + 1);
    for (long long j = 1; j <= m; j++) {
      if (c[i][j] == '\\') {
        long long u = id[i][j], v = id[i + 1][j + 1], fx = find(u),
                  fy = find(v);
        if (fx ^ fy)
          fa[fx] = fy;
        else {
          puts("0");
          return 0;
        }
      } else if (c[i][j] == '/') {
        long long u = id[i + 1][j], v = id[i][j + 1], fx = find(u),
                  fy = find(v);
        if (fx ^ fy)
          fa[fx] = fy;
        else {
          puts("0");
          return 0;
        }
      }
    }
  }
  for (long long i = 1; i <= cnt; i++)
    if (!(find(i) ^ i)) bel[i] = ++num[col[i]];
  memset(mt, 0, sizeof(mt));
  for (long long i = 1; i <= n; i++)
    for (long long j = 1; j <= m; j++) {
      if (c[i][j] != '*') continue;
      long long as = id[i][j], att = id[i + 1][j + 1], is = id[i][j + 1],
                it = id[i + 1][j], fas = find(as), fatt = find(att),
                fis = find(is), fit = find(it);
      if (fas ^ fatt) {
        long long u = bel[fas], v = bel[fatt], opt = col[as];
        mt[opt][u][v] = (mt[opt][u][v] - 1 + mod) % mod,
        mt[opt][v][u] = (mt[opt][v][u] - 1 + mod) % mod,
        mt[opt][u][u] = (mt[opt][u][u] + 1) % mod,
        mt[opt][v][v] = (mt[opt][v][v] + 1) % mod;
      }
      if (fis ^ fit) {
        long long u = bel[fis], v = bel[fit], opt = col[is];
        mt[opt][u][v] = (mt[opt][u][v] - 1 + mod) % mod,
        mt[opt][v][u] = (mt[opt][v][u] - 1 + mod) % mod,
        mt[opt][u][u] = (mt[opt][u][u] + 1) % mod,
        mt[opt][v][v] = (mt[opt][v][v] + 1) % mod;
      }
    }
  put((det(num[0], mt[0]) + det(num[1], mt[1])) % mod);
  puts("");
  return 0;
}
