#include <bits/stdc++.h>
using namespace std;
int mod;
int add(int x, int y) { return x + y < mod ? x + y : x + y - mod; }
int qpow(int x, int k) {
  int r = 1;
  while (k) {
    if (k & 1) r = 1ll * r * x % mod;
    k >>= 1;
    x = 1ll * x * x % mod;
  }
  return r;
}
int n, m;
int id[110][110], tid;
char mt[110][110];
struct UFS {
  int fa[100100];
  void reset() {
    for (int i = 1; i <= tid; ++i) fa[i] = i;
  }
  int find(int x) { return fa[x] == x ? x : fa[x] = find(fa[x]); }
  void merge(int x, int y) {
    int fx = find(x), fy = find(y);
    if (fx == fy) return;
    fa[fx] = fy;
  }
} ufs;
int po[2][100100], tp[2];
struct Matrix {
  int a[1010][1010];
  void ins(int x, int y) {
    if (x == y) return;
    a[x][x] = add(a[x][x], 1);
    a[y][y] = add(a[y][y], 1);
    a[x][y] = add(a[x][y], mod - 1);
    a[y][x] = add(a[y][x], mod - 1);
  }
  int solve(int ma) {
    ma--;
    int t, inv;
    int ans = 1;
    for (int i = 1; i <= ma; ++i) {
      t = -1;
      for (int j = i; j <= ma; ++j)
        if (a[j][i]) {
          t = j;
          break;
        }
      if (t == -1) continue;
      if (t != i) {
        ans = mod - ans;
        swap(a[i], a[t]);
      }
      inv = qpow(a[i][i], mod - 2);
      for (int j = i + 1; j <= ma; ++j) {
        if (!a[j][i]) continue;
        t = 1ll * a[j][i] * inv % mod;
        a[j][i] = 0;
        for (int k = i + 1; k <= ma; ++k)
          a[j][k] = add(a[j][k], mod - 1ll * a[i][k] * t % mod);
      }
    }
    for (int i = 1; i <= ma; ++i) ans = 1ll * ans * a[i][i] % mod;
    return ans;
  }
} mat[2];
int main() {
  scanf("%d%d%d", &n, &m, &mod);
  for (int i = 1; i <= n + 1; ++i)
    for (int j = 1; j <= m + 1; ++j) id[i][j] = ++tid;
  ufs.reset();
  for (int i = 1; i <= n; ++i) {
    scanf("%s", mt[i] + 1);
    for (int j = 1; j <= m; ++j) {
      if (mt[i][j] == '/')
        ufs.merge(id[i][j + 1], id[i + 1][j]);
      else if (mt[i][j] != '*')
        ufs.merge(id[i][j], id[i + 1][j + 1]);
    }
  }
  for (int i = 1, c; i <= n + 1; ++i)
    for (int j = 1; j <= m + 1; ++j) {
      c = ((i + j) & 1);
      if (ufs.find(id[i][j]) == id[i][j]) po[c][id[i][j]] = ++tp[c];
    }
  int x, y, c;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j) {
      if (mt[i][j] != '*') continue;
      c = ((i + j + 1) & 1);
      x = po[c][ufs.find(id[i][j + 1])];
      y = po[c][ufs.find(id[i + 1][j])];
      mat[c].ins(x, y);
      c = ((i + j) & 1);
      x = po[c][ufs.find(id[i][j])];
      y = po[c][ufs.find(id[i + 1][j + 1])];
      mat[c].ins(x, y);
    }
  int ans = add(mat[0].solve(tp[0]), mat[1].solve(tp[1]));
  printf("%d\n", ans);
  return 0;
}
