#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void rd(T &x) {
  x = 0;
  char c = getchar();
  int f = 1;
  while (!isdigit(c)) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (isdigit(c)) x = x * 10 - '0' + c, c = getchar();
  x *= f;
}
int mod;
inline int Pow(int x, int y) {
  int res = 1;
  for (; y; y >>= 1, x = 1ll * x * x % mod)
    if (y & 1) res = 1ll * res * x % mod;
  return res;
}
struct Graph {
  int a[410][410], n;
  void adde(int x, int y) {
    if (x == y) return;
    a[x][y]--, a[y][x]--, a[x][x]++, a[y][y]++;
  }
  int solve(int n) {
    if (n > 201) return 0;
    for (int i = 1; i <= n; ++i)
      for (int j = 1; j <= n; ++j) a[i][j] %= mod;
    --n;
    int res = 1;
    for (int i = 1; i <= n; ++i) {
      for (int j = i; j <= n; ++j)
        if (a[j][i]) {
          if (j != i) {
            for (int k = 1; k <= n; ++k) swap(a[j][k], a[i][k]);
            res = mod - res;
          }
          break;
        }
      if (!a[i][i]) return 0;
      res = 1ll * res * a[i][i] % mod;
      int inv = Pow(a[i][i], mod - 2);
      for (int k = i + 1; k <= n; ++k) {
        int tmp = 1ll * a[k][i] * inv % mod;
        for (int j = 1; j <= n; ++j)
          a[k][j] = (a[k][j] - 1ll * a[i][j] * tmp) % mod;
      }
    }
    return (res + mod) % mod;
  }
} G[2];
const int N = 110;
int fa[N * N], id[N][N], ncnt;
int pid[N * N], pid_cnt[2];
int n, m;
char mp[N][N];
int find(int x) { return fa[x] == x ? x : fa[x] = find(fa[x]); }
bool un(int x, int y) {
  x = find(x), y = find(y);
  if (x == y) return 0;
  fa[x] = y;
  return 1;
}
void adde(int x1, int y1, int x2, int y2) {
  if (pid_cnt[(x1 + y1) % 2] <= 201)
    G[(x1 + y1) % 2].adde(pid[find(id[x1][y1])], pid[find(id[x2][y2])]);
}
int main() {
  rd(n), rd(m), rd(mod);
  for (int i = 1; i <= n + 1; ++i)
    for (int j = 1; j <= m + 1; ++j) id[i][j] = ++ncnt, fa[ncnt] = ncnt;
  int ok[2] = {1, 1};
  for (int i = 1; i <= n; ++i) {
    scanf("%s", mp[i] + 1);
    for (int j = 1; j <= m; ++j) {
      if (mp[i][j] == '/') {
        if (!un(id[i + 1][j], id[i][j + 1])) ok[(i + 1 + j) % 2] = 0;
      }
      if (mp[i][j] == '\\') {
        if (!un(id[i][j], id[i + 1][j + 1])) ok[(i + j) % 2] = 0;
      }
    }
  }
  for (int i = 1; i <= n + 1; ++i)
    for (int j = 1; j <= m + 1; ++j)
      if (!pid[find(id[i][j])]) pid[find(id[i][j])] = ++pid_cnt[(i + j) % 2];
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j)
      if (mp[i][j] == '*') {
        adde(i, j, i + 1, j + 1);
        adde(i + 1, j, i, j + 1);
      }
  int res = ((ok[0] ? G[0].solve(pid_cnt[0]) : 0) +
             (ok[1] ? G[1].solve(pid_cnt[1]) : 0)) %
            mod;
  printf("%d", res);
  return 0;
}
