#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool checkMax(T &a, const T &b) {
  return a < b ? a = b, 1 : 0;
}
template <class T>
inline bool checkMin(T &a, const T &b) {
  return a > b ? a = b, 1 : 0;
}
const int INF = 0x3f3f3f3f;
const long long llINF = 1e18;
const int MAXN = 205;
const int MAXM = MAXN * MAXN;
int n, m, MOD;
int f[MAXM], a[MAXN][MAXN], id[MAXN][MAXN], tag[MAXM];
char s[MAXN][MAXN];
void addmod(int &x, int y) {
  x += y;
  if (x >= MOD) x -= MOD;
}
void submod(int &x, int y) {
  x -= y;
  if (x < 0) x += MOD;
}
int add(int x, int y) {
  addmod(x, y);
  return x;
}
int sub(int x, int y) {
  submod(x, y);
  return x;
}
int Find(int x) {
  if (x == f[x]) return x;
  return f[x] = Find(f[x]);
}
void Union(int x, int y) {
  x = Find(x);
  y = Find(y);
  if (x == y) return;
  f[x] = y;
}
int power(int x, int y) {
  int res = 1;
  while (y) {
    if (y & 1) res = 1ll * res * x % MOD;
    x = 1ll * x * x % MOD;
    y >>= 1;
  }
  return res;
}
void add_edge(int u, int v) {
  addmod(a[u][u], 1);
  addmod(a[v][v], 1);
  submod(a[u][v], 1);
  submod(a[v][u], 1);
}
int Gauss(int n) {
  int res = 1;
  for (int k = 1; k <= n; k++) {
    int pos = k;
    for (int i = k + 1; i <= n; i++) {
      if (abs(a[pos][k]) < abs(a[i][k])) pos = i;
    }
    if (pos != k) res = sub(0, res), swap(a[pos], a[k]);
    res = 1ll * res * a[k][k] % MOD;
    long long inv = power(a[k][k], MOD - 2);
    for (int i = k; i <= n; i++) a[k][i] = 1ll * a[k][i] * inv % MOD;
    for (int i = k + 1; i <= n; i++) {
      for (int j = k + 1; j <= n; j++)
        submod(a[i][j], 1ll * a[i][k] * a[k][j] % MOD);
    }
  }
  return res;
}
int Solve(int t) {
  int tot = 0;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= m; j++) {
      if (((i + j) & 1) == t) id[i][j] = ++tot;
    }
  }
  for (int i = 1; i <= tot; i++) f[i] = i;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (s[i][j] == '/' && ((i + j - 1) & 1) == t)
        Union(id[i - 1][j], id[i][j - 1]);
      if (s[i][j] == '\\' && ((i + j) & 1) == t)
        Union(id[i - 1][j - 1], id[i][j]);
    }
  }
  int cnt = 0;
  for (int i = 1; i <= tot; i++) {
    if (Find(i) == i) tag[i] = ++cnt;
  }
  memset(a, 0, sizeof(a));
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (s[i][j] == '*' && ((i + j - 1) & 1) == t)
        add_edge(tag[Find(id[i - 1][j])], tag[Find(id[i][j - 1])]);
      if (s[i][j] == '*' && ((i + j) & 1) == t)
        add_edge(tag[Find(id[i - 1][j - 1])], tag[Find(id[i][j])]);
    }
  }
  return Gauss(cnt - 1);
}
int main() {
  scanf("%d%d%d", &n, &m, &MOD);
  for (int i = 1; i <= n; i++) scanf("%s", s[i] + 1);
  printf("%d\n", add(Solve(0), Solve(1)));
  return 0;
}
