#include <bits/stdc++.h>
const int N = 205, M = N * N;
int n, m, f[M], cid[M], id[N][N], mod, ans, count;
std::string s[N];
void no() { std::cout << "0\n", std::exit(0); }
int find(int x) { return x == f[x] ? x : f[x] = find(f[x]); }
void link(int x, int y) {
  if (find(x) == find(y)) no();
  f[find(x)] = find(y);
}
void reduce(int &x) { x += x >> 31 & mod; }
int pow(int x, int y, int ans = 1) {
  for (; y; y >>= 1, x = (long long)x * x % mod)
    if (y & 1) ans = (long long)ans * x % mod;
  return ans;
}
struct matrix {
  int a[N][N], size;
  void link(int x, int y) { --a[x][y], --a[y][x], ++a[x][x], ++a[y][y]; }
  void clear() { std::memset(a, 0, sizeof a); }
  int solve() {
    int ans = 1;
    for (int i = 0; i < size; ++i)
      for (int j = 0; j < size; ++j) reduce(a[i][j] %= mod);
    for (int i = 0; i < size; ++i) {
      int row = -1;
      for (int j = i; j < size; ++j)
        if (a[j][i]) row = j;
      if (!~row) return 0;
      for (int j = i; j < size; ++j) std::swap(a[i][j], a[row][j]);
      if (row != i) ans = mod - ans;
      ans = (long long)ans * a[i][i] % mod;
      int inv = pow(a[i][i], mod - 2);
      for (int j = i; j < size; ++j) a[i][j] = (long long)a[i][j] * inv % mod;
      for (int j = i + 1; j < size; ++j) {
        int ratio = mod - a[j][i];
        for (int k = i; k < size; ++k) {
          a[j][k] = (a[j][k] + (long long)ratio * a[i][k]) % mod;
        }
      }
    }
    return ans;
  }
} A;
int main() {
  std::ios::sync_with_stdio(0), std::cin.tie(0);
  std::cin >> n >> m >> mod;
  for (int i = 0; i < n; ++i)
    std::cin >> s[i], count += std::count(s[i].begin(), s[i].end(), '*');
  int bidx = 0, widx = 0;
  for (int i = 0; i <= n; ++i)
    for (int j = i & 1; j <= m; j += 2) id[i][j] = bidx++;
  for (int i = 0; i < bidx; ++i) f[i] = i;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j)
      if (s[i][j] == '/') {
        if (i + j & 1) link(id[i + 1][j], id[i][j + 1]);
      } else if (s[i][j] == '\\') {
        if (i + j & 1 ^ 1) link(id[i][j], id[i + 1][j + 1]);
      }
  int bbidx = 0;
  for (int i = 0; i < bidx; ++i)
    if (i == find(i)) cid[i] = bbidx++;
  if (bbidx <= count + 1) {
    for (int i = 0; i < bidx; ++i) cid[i] = cid[find(i)];
    A.size = bbidx - 1;
    for (int i = 0; i < n; ++i)
      for (int j = 0; j < m; ++j)
        if (s[i][j] == '*') {
          if (i + j & 1 ^ 1)
            A.link(cid[id[i][j]], cid[id[i + 1][j + 1]]);
          else
            A.link(cid[id[i][j + 1]], cid[id[i + 1][j]]);
        }
    ans = (ans + A.solve()) % mod;
  }
  A.clear();
  for (int i = 0; i <= n; ++i)
    for (int j = i & 1 ^ 1; j <= m; j += 2) id[i][j] = widx++;
  for (int i = 0; i < widx; ++i) f[i] = i;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j)
      if (s[i][j] == '/') {
        if (i + j & 1 ^ 1) link(id[i + 1][j], id[i][j + 1]);
      } else if (s[i][j] == '\\') {
        if (i + j & 1) link(id[i][j], id[i + 1][j + 1]);
      }
  int wwidx = 0;
  for (int i = 0; i < widx; ++i)
    if (i == find(i)) cid[i] = wwidx++;
  if (wwidx <= count + 1) {
    for (int i = 0; i < widx; ++i) cid[i] = cid[find(i)];
    A.size = wwidx - 1;
    for (int i = 0; i < n; ++i)
      for (int j = 0; j < m; ++j)
        if (s[i][j] == '*') {
          if (i + j & 1)
            A.link(cid[id[i][j]], cid[id[i + 1][j + 1]]);
          else
            A.link(cid[id[i][j + 1]], cid[id[i + 1][j]]);
        }
    ans = (ans + A.solve()) % mod;
  }
  std::cout << ans << '\n';
  return 0;
}
