#include <bits/stdc++.h>
using namespace std;
const int Max_NM(105);
const int Max_V(405);
int N, M, MOD, V, A[Max_V][Max_V], Father[Max_NM * Max_NM];
char B[Max_NM][Max_NM];
inline int Mult(int a, int b) { return a * 1LL * b % MOD; }
inline int Sub(int a, int b) { return a - b < 0 ? a - b + MOD : a - b; }
int Get_Father(int x) {
  return Father[x] == x ? x : Father[x] = Get_Father(Father[x]);
}
inline int getnumber(int x, int y) { return (x - 1) * (M + 1) + y; }
int Gauss() {
  int Ret(1);
  for (int i = 1; i <= V; ++i)
    for (int j = 1; j <= V; ++j) A[i][j] = (A[i][j] % MOD + MOD) % MOD;
  for (int i = 1; i <= V - 1; ++i) {
    for (int j = i + 1, p; j <= V - 1; ++j)
      while (A[j][i]) {
        p = A[i][i] / A[j][i];
        for (int k = i; k <= V - 1; ++k)
          A[i][k] = Sub(A[i][k], Mult(A[j][k], p)), swap(A[i][k], A[j][k]);
        Ret = Sub(0, Ret);
      }
    Ret = Mult(Ret, A[i][i]);
  }
  return Ret;
}
inline void insert(const int &u, const int &v) {
  --A[u][v], --A[v][u], ++A[u][u], ++A[v][v];
}
int work(int m) {
  for (int i = 1; i <= N + 1; ++i)
    for (int j = 1; j <= M + 1; ++j)
      if ((i & 1) ^ (j & 1) ^ m) Father[getnumber(i, j)] = getnumber(i, j);
  for (int i = 1, u, v; i <= N; ++i)
    for (int j = 1; j <= M; ++j)
      if (B[i][j] != '*') {
        if (B[i][j] == '\\')
          if ((i & 1) ^ (j & 1) ^ m)
            u = getnumber(i, j), v = getnumber(i + 1, j + 1);
          else
            continue;
        else if ((i & 1) ^ (j & 1) ^ m)
          continue;
        else
          u = getnumber(i + 1, j), v = getnumber(i, j + 1);
        if ((u = Get_Father(u)) != (v = Get_Father(v)))
          Father[v] = u;
        else
          return 0;
      }
  map<int, int> S;
  memset(A, 0, sizeof(A)), V = 0;
  for (int i = 1; i <= N + 1; ++i)
    for (int j = 1; j <= M + 1; ++j)
      if ((i & 1) ^ (j & 1) ^ m) S[Get_Father(getnumber(i, j))];
  for (map<int, int>::iterator i = S.begin(); i != S.end(); ++i)
    i->second = ++V;
  for (int i = 1, u, v; i <= N; ++i)
    for (int j = 1; j <= M; ++j)
      if (B[i][j] == '*') {
        if ((i & 1) ^ (j & 1) ^ m)
          u = getnumber(i, j), v = getnumber(i + 1, j + 1);
        else
          u = getnumber(i + 1, j), v = getnumber(i, j + 1);
        insert(S[Get_Father(u)], S[Get_Father(v)]);
      }
  return Gauss();
}
int main() {
  scanf("%d%d%d", &N, &M, &MOD);
  for (int i = 1; i <= N; ++i) scanf("%s", B[i] + 1);
  printf("%d", (work(0) + work(1)) % MOD);
  return 0;
}
