#include <bits/stdc++.h>
using namespace std;
long long f[200010], n, m;
long long find(long long x) { return x == f[x] ? x : find(f[x]); }
void merge(long long x, long long y) { f[find(x)] = find(y); }
long long mod;
long long pw(long long x, long long k = mod - 2) {
  long long r = 1;
  while (k) {
    if (k & 1) r = r * x % mod;
    x = x * x % mod;
    k >>= 1;
  }
  return r;
}
char ch[305][305];
long long g[200010];
struct Graph {
  long long n, lk[305][305];
  void ps(long long a, long long b) {
    a = g[find(a)];
    b = g[find(b)];
    lk[a][b]--;
    lk[b][a]--;
    lk[a][a]++;
    lk[b][b]++;
  }
  long long answer() {
    long long ans = 1;
    for (long long i = 1; i < n; i++) {
      if (!lk[i][i])
        for (long long j = i + 1; j < n; j++) {
          if (lk[j][i]) {
            swap(lk[i], lk[j]);
            ans = -ans;
            break;
          }
        }
      for (long long j = i + 1; j < n; j++) {
        long long t = lk[j][i] * pw(lk[i][i]) % mod;
        t = (t + mod) % mod;
        for (long long k = i; k < n; k++) {
          lk[j][k] -= t * lk[i][k];
          lk[j][k] = (lk[j][k] % mod + mod) % mod;
        }
      }
      ans = ans * lk[i][i] % mod;
    }
    return (ans + mod) % mod;
  }
} G[2];
inline long long id(long long i, long long j) { return i * (m + 1) + j; }
signed main() {
  scanf("%lld%lld%lld", &n, &m, &mod);
  for (long long i = 0; i <= (n + 1) * (m + 1); i++) f[i] = i;
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= m; j++) {
      scanf(" %c", &ch[i][j]);
      if (ch[i][j] == '\\') merge(id(i - 1, j - 1), id(i, j));
      if (ch[i][j] == '/') merge(id(i - 1, j), id(i, j - 1));
    }
  }
  for (long long i = 0; i <= n; i++)
    for (long long j = 0; j <= m; j++)
      if (find(id(i, j)) == id(i, j)) g[id(i, j)] = ++G[(i + j) & 1].n;
  for (long long i = 1; i <= n; i++)
    for (long long j = 1; j <= m; j++)
      if (ch[i][j] == '*') {
        G[(i + j) & 1].ps(id(i, j), id(i - 1, j - 1));
        G[((i + j) & 1) ^ 1].ps(id(i - 1, j), id(i, j - 1));
      }
  printf("%lld\n", (G[1].answer() + G[0].answer()) % mod);
}
