#include <bits/stdc++.h>
using namespace std;
const int N = 605;
int n, m, P, a[N][N], fa[N * N], id[N][N], id2[N * N];
char s[N][N];
inline int pw(int a, int b) {
  int r = 1;
  for (; b; b >>= 1, a = 1ll * a * a % P)
    if (b & 1) r = 1ll * r * a % P;
  return r;
}
int det(int n) {
  int ans = 1;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j) a[i][j] = (a[i][j] + P) % P;
  for (int i = 1; i <= n; ++i) {
    int p = 0;
    for (int j = i; j <= n; ++j)
      if (a[j][i]) {
        p = j;
        break;
      }
    if (!p)
      return 0;
    else if (p != i)
      ans = P - ans;
    if (p != i)
      for (int j = i; j <= n; ++j) swap(a[i][j], a[p][j]);
    for (int j = i + 1; j <= n; ++j) {
      int t = 1ll * a[j][i] * pw(a[i][i], P - 2) % P;
      for (int k = i; k <= n; ++k)
        a[j][k] = (a[j][k] + P - 1ll * t * a[i][k] % P) % P;
    }
    ans = 1ll * ans * a[i][i] % P;
  }
  return ans;
}
inline int fnd(int x) { return fa[x] == x ? x : fa[x] = fnd(fa[x]); }
inline int uni(int x, int y) {
  x = fnd(x);
  y = fnd(y);
  fa[x] = y;
  return x != y;
}
inline void adde(int x, int y) {
  x = id2[fnd(x)];
  y = id2[fnd(y)];
  a[x][x]++;
  a[y][y]++;
  a[x][y]--;
  a[y][x]--;
}
int sol(int o) {
  int cc = 0, tt = 0;
  for (int i = 0; i <= n; ++i)
    for (int j = 0; j <= m; ++j)
      if ((i + j + o) & 1) id[i][j] = ++cc;
  for (int i = 1; i <= cc; ++i) fa[i] = i;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j) {
      char c = (i + j + o) & 1 ? '\\' : '/';
      if (s[i][j] != c) continue;
      if (c == '/') {
        if (!uni(id[i - 1][j], id[i][j - 1])) return 0;
      } else {
        if (!uni(id[i - 1][j - 1], id[i][j])) return 0;
      }
    }
  for (int i = 1; i <= cc; ++i)
    if (fnd(i) == i) id2[i] = ++tt;
  memset(a, 0, sizeof(a));
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j)
      if (s[i][j] == '*') {
        if ((i + j + o) & 1)
          adde(id[i - 1][j - 1], id[i][j]);
        else
          adde(id[i - 1][j], id[i][j - 1]);
      }
  return det(tt - 1);
}
int main() {
  scanf("%d%d%d", &n, &m, &P);
  for (int i = 1; i <= n; ++i) scanf("%s", s[i] + 1);
  printf("%d\n", (sol(0) + sol(1)) % P);
  return 0;
}
