#include <bits/stdc++.h>
namespace mist {
const int W = 103, N = W * W, M = 404;
int MOD;
long long inv(int x) {
  return (x == 1 || x == -1) ? x : (-(MOD / x) * inv(MOD % x) % MOD);
}
struct calculator {
  int s[M][M];
  int n;
  void reset(int init_n) {
    n = init_n;
    memset(s, 0, sizeof(s));
  }
  void add(int x, int y) { s[x][y]--, s[y][x]--, s[x][x]++, s[y][y]++; }
  int calc() {
    n--;
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= n; j++) s[i][j] %= MOD;
    int sign = 1, row = 1, drow;
    for (int col = 1; col <= n; col++) {
      for (drow = row; drow <= n && !s[drow][col]; drow++)
        ;
      if (drow > n) return 0;
      if (drow != row) {
        sign *= -1;
        for (int i = 1; i <= n; i++) std::swap(s[row][i], s[drow][i]);
      }
      for (int i = row + 1; i <= n; i++)
        if (s[i][col]) {
          int x = -s[i][col] * inv(s[row][col]) % MOD;
          for (int j = 1; j <= n; j++)
            s[i][j] = (s[i][j] + (long long)x * s[row][j]) % MOD;
        }
      row++;
    }
    int ret = 1;
    for (int i = 1; i <= n; i++) ret = (long long)ret * s[i][i] % MOD;
    ret *= sign;
    return (ret + MOD) % MOD;
  }
} C;
struct dus {
  int q[N];
  void reset(int n) {
    for (int i = 1; i <= n; i++) q[i] = i;
  }
  int ask(int p) { return p == q[p] ? p : q[p] = ask(q[p]); }
  bool uni(int u, int v) { return ask(u) == ask(v); }
  bool link(int u, int v) {
    if (uni(u, v)) return 0;
    q[ask(u)] = ask(v);
    return 1;
  }
} d;
char G[W][W];
int n, m;
int mp(int x, int y) { return x * (m + 1) + y; }
bool initialize() {
  scanf("%d%d%d", &n, &m, &MOD);
  for (int i = 1; i <= n; i++) scanf("%s", G[i] + 1);
  int total_number = (n + 1) * (m + 1);
  d.reset(total_number), d.reset(total_number);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      if (G[i][j] == '/') {
        int u = mp(i - 1, j), v = mp(i, j - 1), flag = 1;
        flag = d.link(u, v);
        if (!flag) return 0;
      } else if (G[i][j] == '\\') {
        int u = mp(i - 1, j - 1), v = mp(i, j), flag = 1;
        flag = d.link(u, v);
        if (!flag) return 0;
      }
  return 1;
}
int id[N], tot;
int part0() {
  tot = 0;
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= m; j++)
      if (!((i + j) & 1) && d.q[mp(i, j)] == mp(i, j)) id[mp(i, j)] = ++tot;
  C.reset(tot);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      if (G[i][j] == '*') {
        int u, v;
        if ((i + j) & 1)
          u = mp(i - 1, j), v = mp(i, j - 1);
        else
          u = mp(i, j), v = mp(i - 1, j - 1);
        u = id[d.ask(u)], v = id[d.ask(v)];
        C.add(u, v);
      }
  return C.calc();
}
int part1() {
  tot = 0;
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= m; j++)
      if (((i + j) & 1) && d.q[mp(i, j)] == mp(i, j)) id[mp(i, j)] = ++tot;
  C.reset(tot);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      if (G[i][j] == '*') {
        int u, v;
        if ((i + j) & 1)
          u = mp(i, j), v = mp(i - 1, j - 1);
        else
          u = mp(i - 1, j), v = mp(i, j - 1);
        u = id[d.ask(u)], v = id[d.ask(v)];
        C.add(u, v);
      }
  return C.calc();
}
void solve() {
  if (!initialize()) return void(printf("0\n"));
  int ans = (part0() + part1()) % MOD;
  ans = (ans + MOD) % MOD;
  printf("%d\n", ans);
}
}  // namespace mist
int main() {
  mist::solve();
  return 0;
}
