#include <bits/stdc++.h>
using namespace std;
long long n, m, P;
char s[105][105];
long long id[105 * 105];
long long find(long long x) { return id[x] == x ? x : id[x] = find(id[x]); }
void unite(long long x, long long y) { id[find(x)] = find(y); }
long long Pow(long long b, long long x) {
  long long res = 1;
  while (x) {
    if (x & 1) res = res * b % P;
    b = b * b % P;
    x >>= 1;
  }
  return res;
}
long long pn[105 * 105];
struct MatTree {
  long long a[105 * 5][105 * 5], tot;
  void add(long long x, long long y) {
    if (x == y) return;
    a[x][x]++;
    a[y][y]++;
    a[x][y]--;
    a[y][x]--;
  }
  long long solve() {
    for (long long i = 1; i <= tot; i++)
      for (long long j = 1; j <= tot; j++) a[i][j] = (a[i][j] + P) % P;
    long long res = 1;
    for (long long i = 1; i < tot; i++) {
      long long pos = i;
      while (pos < tot && !a[pos][i]) pos++;
      if (pos >= tot) continue;
      if (pos != i) res = P - res, swap(a[pos], a[i]);
      long long inv = Pow(a[i][i], P - 2);
      for (long long j = i + 1; j < tot; j++) {
        long long tmp = inv * a[j][i] % P;
        for (long long k = i; k < tot; k++)
          a[j][k] = (a[j][k] - a[i][k] * tmp % P + P) % P;
      }
    }
    for (long long i = 1; i < tot; i++) res = res * a[i][i] % P;
    return res;
  }
} G[2];
signed main() {
  scanf("%lld%lld%lld", &n, &m, &P);
  for (long long i = 1; i <= n; i++) scanf("%s", s[i] + 1);
  for (long long i = 1; i <= (n + 1) * (m + 1); i++) id[i] = i;
  for (long long i = 1; i <= n; i++)
    for (long long j = 1; j <= m; j++) {
      if (s[i][j] == '/')
        unite((((i + 1) - 1) * (m + 1) + (j)), (((i)-1) * (m + 1) + (j + 1)));
      else if (s[i][j] == '\\')
        unite((((i)-1) * (m + 1) + (j)), (((i + 1) - 1) * (m + 1) + (j + 1)));
    }
  for (long long i = 1; i <= n + 1; i++)
    for (long long j = 1; j <= m + 1; j++) {
      long long tt = (((i)-1) * (m + 1) + (j));
      if (find(tt) == tt) G[(i + j) & 1].tot++, pn[tt] = G[(i + j) & 1].tot;
    }
  for (long long i = 1; i <= n; i++)
    for (long long j = 1; j <= m; j++)
      if (s[i][j] == '*') {
        G[(i + j) & 1].add(pn[find((((i)-1) * (m + 1) + (j)))],
                           pn[find((((i + 1) - 1) * (m + 1) + (j + 1)))]);
        G[(i + j + 1) & 1].add(pn[find((((i + 1) - 1) * (m + 1) + (j)))],
                               pn[find((((i)-1) * (m + 1) + (j + 1)))]);
      }
  long long ans = (G[0].solve() + G[1].solve()) % P;
  cout << ans << endl;
  return 0;
}
