#include <bits/stdc++.h>
using namespace std;
const int N = 105;
const int T = 205;
const int S = N * N;
const int V = T << 1;
int fa[S], lab[S];
char MAP[N][N];
int n, m, s, P, idx, ans;
bool cir = 0;
inline int quick_power(int x, int y) {
  int ret = 1;
  for (; y; y >>= 1, x = 1ll * x * x % P)
    if (y & 1) ret = 1ll * ret * x % P;
  return ret;
}
int getfather(int son) {
  return fa[son] == son ? son : fa[son] = getfather(fa[son]);
}
inline bool merge(int x, int y) {
  x = getfather(x), y = getfather(y);
  if (x == y) return 0;
  return fa[y] = x, 1;
}
struct matrix {
  int num[V][V];
  int n;
  inline void init(int n_ = 0) {
    n = n_;
    for (int i = 0; i < n; ++i)
      for (int j = 0; j < n; ++j) num[i][j] = 0;
  }
  inline int det() {
    bool sig = 1;
    for (int i = 0; i < n; ++i) {
      if (!num[i][i])
        for (int j = i + 1; j < n; ++j)
          if (num[j][i]) {
            sig ^= 1;
            for (int k = 0; k < n; ++k) swap(num[i][k], num[j][k]);
            break;
          }
      if (num[i][i])
        for (int j = i + 1, inv = quick_power(num[i][i], P - 2); j < n; ++j)
          if (num[j][i])
            for (int k = 0, mul = 1ll * num[j][i] * inv % P; k < n; ++k)
              (num[j][k] += P - 1ll * num[i][k] * mul % P) %= P;
    }
    int ret = 1;
    for (int i = 0; i < n; ++i) ret = 1ll * ret * num[i][i] % P;
    return sig > 0 ? ret : P - ret;
  }
} Kir;
inline int getid(int x, int y) { return x * (m + 1) + y; }
inline void addedge(int x, int y) {
  (++Kir.num[x][x]) %= P, (++Kir.num[y][y]) %= P, (Kir.num[x][y] += P - 1) %= P,
      (Kir.num[y][x] += P - 1) %= P;
}
int main() {
  scanf("%d%d%d", &n, &m, &P), s = (n + 1) * (m + 1);
  for (int x = 0; x < s; ++x) fa[x] = x;
  for (int i = 0; !cir && i < n; ++i) {
    scanf("%s", MAP[i]);
    for (int j = 0; !cir && j < m; ++j)
      if (MAP[i][j] == '/')
        cir |= !merge(getid(i + 1, j), getid(i, j + 1));
      else if (MAP[i][j] == '\\')
        cir |= !merge(getid(i, j), getid(i + 1, j + 1));
  }
  if (cir)
    printf("0\n");
  else {
    for (int x = 0; x < s; ++x) lab[x] = -1;
    idx = 0;
    for (int i = 0, x; i <= n; ++i)
      for (int j = 0; j <= m; ++j)
        if ((i ^ j ^ 1) & 1) {
          x = getid(i, j);
          if (getfather(x) == x) lab[x] = idx++;
        }
    Kir.init(idx);
    for (int i = 0; i < n; ++i)
      for (int j = 0; j < m; ++j)
        if (MAP[i][j] == '*')
          if ((i ^ j ^ 1) & 1)
            addedge(lab[fa[getid(i, j)]], lab[fa[getid(i + 1, j + 1)]]);
          else
            addedge(lab[fa[getid(i + 1, j)]], lab[fa[getid(i, j + 1)]]);
    --Kir.n, ans = Kir.det();
    for (int x = 0; x < s; ++x) lab[x] = -1;
    idx = 0;
    for (int i = 0, x; i <= n; ++i)
      for (int j = 0; j <= m; ++j)
        if ((i ^ j) & 1) {
          x = getid(i, j);
          if (getfather(x) == x) lab[x] = idx++;
        }
    Kir.init(idx);
    for (int i = 0; i < n; ++i)
      for (int j = 0; j < m; ++j)
        if (MAP[i][j] == '*')
          if ((i ^ j) & 1)
            addedge(lab[fa[getid(i, j)]], lab[fa[getid(i + 1, j + 1)]]);
          else
            addedge(lab[fa[getid(i + 1, j)]], lab[fa[getid(i, j + 1)]]);
    --Kir.n, (ans += Kir.det()) %= P, printf("%d\n", ans);
  }
  return 0;
}
