#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline bool chkmin(T &x, T y) {
  return y < x ? x = y, 1 : 0;
}
template <typename T>
inline bool chkmax(T &x, T y) {
  return x < y ? x = y, 1 : 0;
}
const int INF = 0x3f3f3f3f;
const int N = 1e2 + 10, K = 300 + 10;
int Mp[N][N], fa[N * N], Id[N * N], G[K][K];
int n, m, mod;
char str[N];
inline int read() {
  int x = 0, flag = 1;
  char ch = getchar();
  while (!isdigit(ch) && ch != '-') ch = getchar();
  if (ch == '-') flag = -1, ch = getchar();
  while (isdigit(ch)) x = (x << 3) + (x << 1) + (ch - '0'), ch = getchar();
  return x * flag;
}
inline int fpm(int a, int b) {
  int res = 1;
  while (b) {
    if (b & 1) res = 1ll * res * a % mod;
    a = 1ll * a * a % mod, b /= 2;
  }
  return res;
}
inline int find(int x) { return fa[x] == x ? x : fa[x] = find(fa[x]); }
inline int Getid(int x, int y) { return ((x - 1) * (m + 1) + y + 1) / 2; }
inline void Merge(int x, int y) {
  x = find(x), y = find(y);
  if (x ^ y)
    fa[x] = y;
  else
    puts("0"), exit(0);
}
inline int Solve(int id) {
  memset(G, 0, sizeof(G));
  for (int i = (1), iend = (((n + 1) * (m + 1) + 1 - id) / 2); i <= iend; i++)
    fa[i] = i;
  for (int i = (1), iend = (n); i <= iend; i++)
    for (int j = (1), jend = (m); j <= jend; j++) {
      if ((((i + j) & 1) != id) && Mp[i][j] == 1)
        Merge(Getid(i, j + 1), Getid(i + 1, j));
      if ((((i + j) & 1) == id) && Mp[i][j] == 2)
        Merge(Getid(i, j), Getid(i + 1, j + 1));
    }
  int cnt = 0;
  for (int i = (1), iend = (((n + 1) * (m + 1) + 1 - id) / 2); i <= iend; i++)
    if (find(i) == i) Id[i] = ++cnt;
  if (cnt > 301) return 0;
  for (int i = (1), iend = (n); i <= iend; i++)
    for (int j = (1), jend = (m); j <= jend; j++) {
      if ((((i + j) & 1) != id) && !Mp[i][j])
        G[Id[find(Getid(i, j + 1))]][Id[find(Getid(i + 1, j))]]--;
      if ((((i + j) & 1) == id) && !Mp[i][j])
        G[Id[find(Getid(i, j))]][Id[find(Getid(i + 1, j + 1))]]--;
    }
  for (int i = (1), iend = (cnt); i <= iend; i++) {
    for (int j = (i + 1), jend = (cnt); j <= jend; j++) {
      int x = G[i][j], y = G[j][i];
      G[i][j] = G[j][i] = x + y;
    }
    int sum = 0;
    for (int j = (1), jend = (cnt); j <= jend; j++)
      if (j ^ i) sum -= G[i][j];
    G[i][i] = sum;
  }
  int ans = 1;
  cnt--;
  for (int i = (1), iend = (cnt); i <= iend; i++) {
    if (!G[i][i])
      for (int j = (i + 1), jend = (cnt); j <= jend; j++)
        if (G[j][i]) {
          swap(G[i], G[j]), ans = 1ll * ans * (mod - 1) % mod;
          break;
        }
    for (int j = (i + 1), jend = (cnt); j <= jend; j++) {
      int val = 1ll * G[j][i] * fpm(G[i][i], mod - 2) % mod;
      for (int k = (i), kend = (cnt); k <= kend; k++)
        G[j][k] = (G[j][k] - 1ll * G[i][k] * val) % mod;
    }
    ans = 1ll * ans * G[i][i] % mod;
  }
  return (ans + mod) % mod;
}
int main() {
  n = read(), m = read(), mod = read();
  for (int i = (1), iend = (n); i <= iend; i++) {
    scanf("%s", str + 1);
    for (int j = (1), jend = (m); j <= jend; j++) {
      if (str[j] == '/')
        Mp[i][j] = 1;
      else if (str[j] == '\\')
        Mp[i][j] = 2;
    }
  }
  printf("%d\n", (Solve(0) + Solve(1)) % mod);
  return 0;
}
