#include <bits/stdc++.h>
using namespace std;
const int MAXN = 605;
int MOD;
inline int add(int x, int y) { return x + y < MOD ? x + y : x + y - MOD; }
inline int dec(int x, int y) { return x < y ? x - y + MOD : x - y; }
inline void ADD(int& x, int y) {
  x += y;
  if (x >= MOD) x -= MOD;
}
inline void DEC(int& x, int y) {
  x -= y;
  if (x < 0) x += MOD;
}
long long q_pow(long long a, long long b, long long p = MOD) {
  long long ret = 1;
  for (; b; a = a * a % p, b >>= 1)
    if (b & 1) ret = ret * a % p;
  return ret;
}
long long inv(long long x, long long p = MOD) { return q_pow(x, p - 2, p); }
int N, M, fa[MAXN * MAXN], a0[MAXN * MAXN], a1[MAXN * MAXN], id0, id1;
int G0[MAXN][MAXN], G1[MAXN][MAXN];
char S[MAXN][MAXN];
int get(int x) { return x == fa[x] ? x : get(fa[x]); }
inline int id(int x, int y) { return x * (M + 1) + y + 1; }
int A[MAXN][MAXN];
int Det(int n) {
  int ans = 1;
  for (int i = 1; i <= n; ++i) {
    int mx = 0;
    for (int j = i; j <= n; ++j)
      if (A[j][i]) mx = j;
    if (mx != i) swap(A[i], A[mx]), ans = dec(0, ans);
    int iv = inv(A[i][i]);
    for (int j = i + 1; j <= n; ++j) {
      int tmp = 1ll * A[j][i] * iv % MOD;
      for (int k = i; k <= n; ++k) DEC(A[j][k], 1ll * tmp * A[i][k] % MOD);
    }
    ans = 1ll * ans * A[i][i] % MOD;
  }
  return ans;
}
int main() {
  scanf("%d%d%d", &N, &M, &MOD);
  for (int i = 1; i <= (N + 1) * (M + 1); ++i) fa[i] = i;
  for (int i = 1; i <= N; ++i) {
    scanf("%s", S[i] + 1);
    for (int j = 1; j <= M; ++j) {
      if (S[i][j] == '\\')
        fa[get(id(i - 1, j - 1))] = get(id(i, j));
      else if (S[i][j] == '/') {
        fa[get(id(i - 1, j))] = get(id(i, j - 1));
      }
    }
  }
  for (int i = 0; i <= N; ++i)
    for (int j = 0; j <= M; ++j)
      if (fa[id(i, j)] == id(i, j)) {
        if ((i + j) & 1)
          a1[id(i, j)] = ++id1;
        else
          a0[id(i, j)] = ++id0;
      }
  for (int i = 0; i <= N; ++i)
    for (int j = 0; j <= M; ++j) {
      if ((i + j) & 1)
        a1[id(i, j)] = a1[get(id(i, j))];
      else
        a0[id(i, j)] = a0[get(id(i, j))];
    }
  for (int i = 1; i <= N; ++i)
    for (int j = 1; j <= M; ++j)
      if (S[i][j] == '*') {
        if ((i + j) % 2 == 0) {
          ++G0[a0[id(i - 1, j - 1)]][a0[id(i, j)]],
              ++G0[a0[id(i, j)]][a0[id(i - 1, j - 1)]];
          ++G1[a1[id(i - 1, j)]][a1[id(i, j - 1)]],
              ++G1[a1[id(i, j - 1)]][a1[id(i - 1, j)]];
        } else {
          ++G1[a1[id(i - 1, j - 1)]][a1[id(i, j)]],
              ++G1[a1[id(i, j)]][a1[id(i - 1, j - 1)]];
          ++G0[a0[id(i - 1, j)]][a0[id(i, j - 1)]],
              ++G0[a0[id(i, j - 1)]][a0[id(i - 1, j)]];
        }
      }
  int ans = 0;
  for (int i = 1; i <= id0; ++i)
    for (int j = 1; j <= id0; ++j) A[i][i] += G0[i][j], A[i][j] -= G0[i][j];
  for (int i = 1; i <= id0; ++i)
    for (int j = 1; j <= id0; ++j)
      if (A[i][j] < 0) A[i][j] += MOD;
  ADD(ans, Det(id0 - 1));
  for (int i = 1; i <= id1; ++i)
    for (int j = 1; j <= id1; ++j) A[i][j] = 0;
  for (int i = 1; i <= id1; ++i)
    for (int j = 1; j <= id1; ++j) A[i][i] += G1[i][j], A[i][j] -= G1[i][j];
  for (int i = 1; i <= id1; ++i)
    for (int j = 1; j <= id1; ++j)
      if (A[i][j] < 0) A[i][j] += MOD;
  ADD(ans, Det(id1 - 1));
  printf("%d\n", ans);
  return 0;
}
