#include <bits/stdc++.h>
using namespace std;
int getint() {
  int ans = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    ans = ans * 10 + c - '0';
    c = getchar();
  }
  return ans * f;
}
const int N = 160, K = 410;
int mod;
int n, m;
char a[N][N];
int f[N * N];
int p2i(int x, int y) { return x * m + y; }
int _(int x) { return x == f[x] ? x : f[x] = _(f[x]); }
int _(int x, int y) { return _(p2i(x, y)); }
int num[N * N];
int mat[K][K];
int qpow(int x, int y) {
  int ans = 1;
  while (y) {
    if (y & 1) ans = ans * 1ll * x % mod;
    x = x * 1ll * x % mod;
    y >>= 1;
  }
  return ans;
}
int calc(int n) {
  int ans = 1;
  for (int i = 0; i < n; i++) {
    if (mat[i][i] == 0) {
      for (int j = i + 1; j < n; j++) {
        if (mat[j][i]) swap(mat[j], mat[i]), ans *= -1;
      }
      if (!mat[i][i]) {
        return 0;
      }
    }
    int v = qpow(mat[i][i], mod - 2);
    for (int j = i + 1; j < n; j++) {
      int t = v * 1ll * mat[j][i] % mod;
      for (int k = i; k < n; k++) {
        mat[j][k] = (mat[j][k] + mod - t * 1ll * mat[i][k] % mod) % mod;
      }
    }
    ans = ans * 1ll * mat[i][i] % mod;
  }
  return (ans + mod) % mod;
}
int main() {
  n = getint(), m = getint(), mod = getint();
  for (int i = 0; i < n; i++) scanf("%s", a[i]);
  ++n, ++m;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) f[p2i(i, j)] = p2i(i, j);
  bool b[2] = {1, 1};
  for (int i = 0; i < n - 1; i++) {
    for (int j = 0; j < m - 1; j++) {
      if (a[i][j] == '\\') {
        if (_(i, j) == _(i + 1, j + 1)) b[(i + j) & 1] = 0;
        f[_(i, j)] = _(i + 1, j + 1);
      }
      if (a[i][j] == '/') {
        if (_(i, j + 1) == _(i + 1, j)) b[(i + j + 1) & 1] = 0;
        f[_(i, j + 1)] = _(i + 1, j);
      }
    }
  }
  int l[2] = {0, 0};
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (_(i, j) == p2i(i, j)) num[_(i, j)] = l[(i + j) & 1]++;
    }
  }
  int ans = 0;
  if (b[0]) {
    for (int i = 0; i < n - 1; i++) {
      for (int j = 0; j < m - 1; j++) {
        if ((i + j + 1) & 1) {
          if (_(i, j) != _(i + 1, j + 1) && a[i][j] != '/')
            mat[num[_(i, j)]][num[_(i + 1, j + 1)]]--,
                mat[num[_(i + 1, j + 1)]][num[_(i, j)]]--,
                mat[num[_(i, j)]][num[_(i, j)]]++,
                mat[num[_(i + 1, j + 1)]][num[_(i + 1, j + 1)]]++;
        } else {
          if (_(i, j + 1) != _(i + 1, j) && a[i][j] != '\\')
            mat[num[_(i, j + 1)]][num[_(i + 1, j)]]--,
                mat[num[_(i + 1, j)]][num[_(i, j + 1)]]--,
                mat[num[_(i, j + 1)]][num[_(i, j + 1)]]++,
                mat[num[_(i + 1, j)]][num[_(i + 1, j)]]++;
        }
      }
    }
    for (int i = 0; i < l[0]; i++) {
      for (int j = 0; j < l[0]; j++)
        if (mat[i][j] < 0) mat[i][j] += mod;
    }
    ans += calc(l[0] - 1);
  }
  if (b[1]) {
    memset(mat, 0, sizeof(mat));
    for (int i = 0; i < n - 1; i++) {
      for (int j = 0; j < m - 1; j++) {
        if ((i + j) & 1) {
          if (_(i, j) != _(i + 1, j + 1) && a[i][j] != '/')
            mat[num[_(i, j)]][num[_(i + 1, j + 1)]]--,
                mat[num[_(i + 1, j + 1)]][num[_(i, j)]]--,
                mat[num[_(i, j)]][num[_(i, j)]]++,
                mat[num[_(i + 1, j + 1)]][num[_(i + 1, j + 1)]]++;
        } else {
          if (_(i, j + 1) != _(i + 1, j) && a[i][j] != '\\')
            mat[num[_(i, j + 1)]][num[_(i + 1, j)]]--,
                mat[num[_(i + 1, j)]][num[_(i, j + 1)]]--,
                mat[num[_(i, j + 1)]][num[_(i, j + 1)]]++,
                mat[num[_(i + 1, j)]][num[_(i + 1, j)]]++;
        }
      }
    }
    for (int i = 0; i < l[1]; i++) {
      for (int j = 0; j < l[1]; j++)
        if (mat[i][j] < 0) mat[i][j] += mod;
    }
    ans += calc(l[1] - 1);
  }
  cout << ans % mod << endl;
}
