#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > v;
int n, m, k, mod, a[105 << 1][105 << 1], pos[105 * 105], f[105 * 105];
char s[105][105];
int id(int x, int y) { return x * (m + 1) + y + 1; }
int find(int k) {
  if (k == f[k]) return k;
  return f[k] = find(f[k]);
}
bool merge(int x, int y) {
  x = find(x), y = find(y);
  if (x == y) return 0;
  f[x] = y;
  return 1;
}
int pow(int n, int m) {
  int s = n, ans = 1;
  while (m) {
    if (m & 1) ans = 1LL * ans * s % mod;
    s = 1LL * s * s % mod;
    m >>= 1;
  }
  return ans;
}
int guess(int n) {
  int ans = 1;
  for (int i = 1; i <= n; i++) {
    int k = -1;
    for (int j = i; j <= n; j++)
      if (a[j][i]) {
        k = j;
        break;
      }
    if (k < 0) return 0;
    if (k != i) {
      ans = mod - ans;
      for (int j = i; j <= n; j++) swap(a[i][j], a[k][j]);
    }
    ans = 1LL * ans * a[i][i] % mod;
    int s = pow(a[i][i], mod - 2);
    for (int j = i; j <= n; j++) a[i][j] = 1LL * a[i][j] * s % mod;
    for (int j = i + 1; j <= n; j++) {
      int s = a[j][i];
      for (int k = i; k <= n; k++)
        a[j][k] = (a[j][k] - 1LL * s * a[i][k] % mod + mod) % mod;
    }
  }
  return ans;
}
int calc(int p) {
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= m; j++)
      if ((i + j) % 2 == p) f[id(i, j)] = id(i, j);
  v.clear();
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      if ((i + j) % 2 == p) {
        if (s[i][j] == '*') v.push_back(make_pair(id(i, j), id(i + 1, j + 1)));
        if (s[i][j] == '\\') {
          if (!merge(id(i, j), id(i + 1, j + 1))) return 0;
        }
      } else {
        if (s[i][j] == '*') v.push_back(make_pair(id(i, j + 1), id(i + 1, j)));
        if (s[i][j] == '/') {
          if (!merge(id(i, j + 1), id(i + 1, j))) return 0;
        }
      }
  pos[0] = 0;
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= m; j++)
      if (((i + j) % 2 == p) && (f[id(i, j)] == id(i, j)))
        pos[id(i, j)] = ++pos[0];
  if (pos[0] > k + 1) return 0;
  memset(a, 0, sizeof(a));
  for (int i = 0; i < v.size(); i++) {
    int x = pos[find(v[i].first)], y = pos[find(v[i].second)];
    if (x < pos[0]) a[x][x] = (a[x][x] + 1) % mod;
    if (y < pos[0]) a[y][y] = (a[y][y] + 1) % mod;
    if ((x < pos[0]) && (y < pos[0])) {
      a[x][y] = (a[x][y] + mod - 1) % mod;
      a[y][x] = (a[y][x] + mod - 1) % mod;
    }
  }
  return guess(pos[0] - 1);
}
int main() {
  scanf("%d%d%d", &n, &m, &mod);
  for (int i = 0; i < n; i++) {
    scanf("%s", s[i]);
    for (int j = 0; j < m; j++)
      if (s[i][j] == '*') k++;
  }
  printf("%d", (calc(0) + calc(1)) % mod);
}
