#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline T read(register T& t) {
  register T f = 1;
  register char ch = getchar();
  t = 0;
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -f;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') t = t * 10 + ch - '0', ch = getchar();
  t *= f;
  return t;
}
template <typename T, typename... Args>
inline void read(T& t, Args&... args) {
  read(t);
  read(args...);
}
long long p;
inline long long power(register long long x, register long long k = p - 2) {
  register long long re = 1;
  for (; k; k >>= 1, x = x * x % p)
    if (k & 1) re = re * x % p;
  return re;
}
int n, m;
int fa[1005 * 1005];
inline int find(int x) {
  if (fa[x] == x) return x;
  return fa[x] = find(fa[x]);
}
inline void merge(int x, int y) {
  int fat = find(x), fbt = find(y);
  if (fat == fbt) return;
  fa[fat] = fbt;
}
long long gs[3005][3005];
long long Gauss(int n) {
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) gs[i][j] = (gs[i][j] + p) % p;
  long long sign = 1;
  for (int i = 2; i <= n; i++) {
    if (gs[i][i] == 0) {
      for (int j = i + 1; j <= n; j++)
        if (gs[j][i]) swap(gs[i], gs[j]), sign = -sign;
    }
    long long inv = power(gs[i][i]);
    for (int j = i + 1; j <= n; j++) {
      long long tp = inv * gs[j][i] % p;
      for (int k = i + 1; k <= n; k++)
        gs[j][k] = (gs[j][k] - gs[i][k] * tp % p + p) % p;
    }
  }
  for (int i = 2; i <= n; i++) sign = (sign * gs[i][i] + p) % p;
  return (sign + p) % p;
}
int id[10000005], id_top;
char c[3005][3005];
bool col[305][305];
int main() {
  read(n, m, p);
  for (int i = 1; i <= (((n + 1) - 1) * (m + 1) + (m + 1)); i++) fa[i] = i;
  for (int i = 1; i <= n; i++) {
    scanf("%s", c[i] + 1);
    for (int j = 1; j <= m; j++) {
      if (c[i][j] == '\\')
        merge((((i)-1) * (m + 1) + (j)), (((i + 1) - 1) * (m + 1) + (j + 1)));
      if (c[i][j] == '/')
        merge((((i)-1) * (m + 1) + (j + 1)), (((i + 1) - 1) * (m + 1) + (j)));
    }
  }
  for (int i = 1; i <= m + 1; i++) col[1][i] = i & 1;
  for (int i = 2; i <= n + 1; i++)
    for (int j = 1; j <= m + 1; j++) col[i][j] = col[i - 1][j] ^ 1;
  long long ans = 0;
  for (int i = 1; i <= n + 1; i++)
    for (int j = 1; j <= m + 1; j++)
      if (col[i][j] == 1 &&
          find((((i)-1) * (m + 1) + (j))) == (((i)-1) * (m + 1) + (j)))
        id[(((i)-1) * (m + 1) + (j))] = ++id_top;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      if (c[i][j] == '*') {
        if (col[i][j] == 1) {
          int a = id[find((((i)-1) * (m + 1) + (j)))],
              b = id[find((((i + 1) - 1) * (m + 1) + (j + 1)))];
          gs[a][a]++;
          gs[a][b]--;
          gs[b][b]++;
          gs[b][a]--;
        }
        if (col[i][j + 1] == 1) {
          int a = id[find((((i)-1) * (m + 1) + (j + 1)))],
              b = id[find((((i + 1) - 1) * (m + 1) + (j)))];
          gs[a][a]++;
          gs[a][b]--;
          gs[b][b]++;
          gs[b][a]--;
        }
      }
  ans += Gauss(id_top);
  memset(gs, 0, sizeof(gs));
  id_top = 0;
  for (int i = 1; i <= n + 1; i++)
    for (int j = 1; j <= m + 1; j++)
      if (col[i][j] == 0 &&
          find((((i)-1) * (m + 1) + (j))) == (((i)-1) * (m + 1) + (j)))
        id[(((i)-1) * (m + 1) + (j))] = ++id_top;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      if (c[i][j] == '*') {
        if (col[i][j] == 0) {
          int a = id[find((((i)-1) * (m + 1) + (j)))],
              b = id[find((((i + 1) - 1) * (m + 1) + (j + 1)))];
          gs[a][a]++;
          gs[a][b]--;
          gs[b][b]++;
          gs[b][a]--;
        }
        if (col[i][j + 1] == 0) {
          int a = id[find((((i)-1) * (m + 1) + (j + 1)))],
              b = id[find((((i + 1) - 1) * (m + 1) + (j)))];
          gs[a][a]++;
          gs[a][b]--;
          gs[b][b]++;
          gs[b][a]--;
        }
      }
  ans += Gauss(id_top);
  printf("%lld\n", ans % p);
  return 0;
}
