#include <bits/stdc++.h>
using namespace std;
const int MaxN = 410, MaxInd = MaxN * MaxN;
char Map[MaxN][MaxN];
int Mod, N, M, F[2][MaxN][MaxN], Hash[MaxN][MaxN], HTot, Fn[2];
class Union_find_set {
 public:
  int F[MaxInd];
  void Init(int N) {
    for (int i = 1, __end = N; i <= __end; ++i) F[i] = i;
  }
  int Find(int X) { return F[X] == X ? X : F[X] = Find(F[X]); }
  void Union(int x, int y) { F[Find(x)] = Find(y); }
} UF;
map<int, int> Discrete[2];
inline long long Power(long long x, int l) {
  long long ret = 1;
  for (; l; l >>= 1, x = x * x % Mod)
    if (l & 1) ret = ret * x % Mod;
  return ret;
}
int Det(int F[MaxN][MaxN], int N) {
  for (int i = 1, __end = N; i <= __end; ++i)
    for (int j = 1, __end = N; j <= __end; ++j) F[i][j] %= Mod;
  bool flag = 0;
  for (int i = 1, __end = N; i <= __end; ++i) {
    if (!F[i][i]) {
      flag ^= 1;
      int pos = i + 1;
      while ((pos <= N) && !F[pos][i]) pos++;
      if (pos > N) return 0;
      for (int j = 1, __end = N; j <= __end; ++j) swap(F[i][j], F[pos][j]);
    }
    long long inv = Power(F[i][i], Mod - 2);
    for (int j = i + 1, __end = N; j <= __end; ++j)
      if (F[j][i]) {
        long long tmp = inv * F[j][i] % Mod;
        for (int k = i, __end = N; k <= __end; ++k) {
          F[j][k] = (F[j][k] - tmp * F[i][k]) % Mod;
          if (F[j][k] < 0) F[j][k] += Mod;
        }
      }
  }
  long long ret = 1;
  for (int i = 1, __end = N; i <= __end; ++i) ret = ret * F[i][i] % Mod;
  if (flag) ret = (Mod - ret) % Mod;
  return ret;
}
int main() {
  scanf("%d%d%d", &N, &M, &Mod);
  for (int i = 1, __end = N; i <= __end; ++i) scanf("%s", Map[i] + 1);
  int tot = 0;
  for (int i = 1, __end = N + 1; i <= __end; ++i)
    for (int j = 1, __end = M + 1; j <= __end; ++j) Hash[i][j] = ++tot;
  UF.Init(tot);
  for (int i = 1, __end = N; i <= __end; ++i)
    for (int j = 1, __end = M; j <= __end; ++j)
      if (Map[i][j] == '/')
        UF.Union(Hash[i + 1][j], Hash[i][j + 1]);
      else if (Map[i][j] == '\\') {
        UF.Union(Hash[i + 1][j + 1], Hash[i][j]);
      }
  for (int i = 1, __end = N + 1; i <= __end; ++i)
    for (int j = 1, __end = M + 1; j <= __end; ++j) {
      int t = (i + j) & 1, u = UF.Find(Hash[i][j]);
      if (Discrete[t][u] == 0) Discrete[t][u] = ++Fn[t];
    }
  for (int i = 1, __end = N; i <= __end; ++i)
    for (int j = 1, __end = M; j <= __end; ++j)
      if (Map[i][j] == '*') {
        if (UF.Find(Hash[i][j]) != UF.Find(Hash[i + 1][j + 1])) {
          int t = (i + j) & 1, u = UF.Find(Hash[i][j]),
              v = UF.Find(Hash[i + 1][j + 1]);
          u = Discrete[t][u];
          v = Discrete[t][v];
          F[t][u][v]++;
          F[t][v][u]++;
        }
        if (UF.Find(Hash[i + 1][j]) != UF.Find(Hash[i][j + 1])) {
          int t = (i + j + 1) & 1, u = UF.Find(Hash[i + 1][j]),
              v = UF.Find(Hash[i][j + 1]);
          u = Discrete[t][u];
          v = Discrete[t][v];
          F[t][u][v]++;
          F[t][v][u]++;
        }
      }
  for (int t = 0, __end = 1; t <= __end; ++t)
    for (int i = 1, __end = Fn[t]; i <= __end; ++i)
      for (int j = 1, __end = Fn[t]; j <= __end; ++j)
        if (i != j) {
          F[t][i][i] += F[t][i][j];
          F[t][i][j] = Mod - F[t][i][j] % Mod;
        }
  int ans = (Det(F[0], Fn[0] - 1) + Det(F[1], Fn[1] - 1)) % Mod;
  cout << ans << endl;
  return 0;
}
