#include <bits/stdc++.h>
using namespace std;
const int NN = 100 + 117;
const int MM = 300 + 117;
int read() {
  int fl = 1, x;
  char c;
  for (c = getchar(); (c < '0' || c > '9') && c != '-'; c = getchar())
    ;
  if (c == '-') {
    fl = -1;
    c = getchar();
  }
  for (x = 0; c >= '0' && c <= '9'; c = getchar())
    x = (x << 3) + (x << 1) + c - '0';
  return x * fl;
}
void open() { freopen("a.in", "r", stdin); }
void close() {
  fclose(stdin);
  fclose(stdout);
}
int m, n;
int mod;
vector<int> p[NN * NN] = {};
vector<int> e[NN * NN] = {};
void link(vector<int> e[], int x, int y) {
  e[x].push_back(y);
  e[y].push_back(x);
}
int col[NN * NN] = {};
int zh[NN * NN] = {};
int id(int x, int y) { return (x - 1) * m + y; }
char s[NN][NN] = {};
long long ans = 0;
long long mat[MM][MM] = {};
bool cir = 0;
void dfs(int c, int x, int fa) {
  col[x] = c;
  for (int i = 0; i < p[x].size(); ++i) {
    int cur = p[x][i];
    if (cur != fa) {
      if (col[cur]) {
        cir = 1;
      } else
        dfs(c, cur, x);
    }
  }
}
long long ksm(long long a, long long b) {
  long long ret = 1;
  for (; b; b >>= 1, a = a * a % mod)
    if (b & 1) ret = ret * a % mod;
  return ret;
}
long long det(int n) {
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j) mat[i][j] %= mod;
  for (int i = 1; i <= n; ++i) {
    if (!mat[i][i]) {
      int pos = -1;
      for (int j = i; j <= n; ++j) {
        if (mat[j][i]) pos = j;
      }
      if (pos == -1) return 0;
      for (int j = i; j <= n; ++j) {
        swap(mat[i][j], mat[pos][j]);
        mat[i][j] = -mat[i][j];
      }
    }
    long long ni = ksm(mat[i][i], mod - 2);
    for (int j = i + 1; j <= n; ++j) {
      if (!mat[j][i]) continue;
      long long mul = (-mat[j][i] * ni) % mod;
      for (int k = i; k <= n; ++k) {
        mat[j][k] = (mat[j][k] + mat[i][k] * mul) % mod;
      }
    }
  }
  long long ans = 1;
  for (int i = 1; i <= n; ++i) {
    ans = (ans * mat[i][i]) % mod;
  }
  return ans;
}
void calc(int kd) {
  int cnt = 0;
  int all = n * m;
  for (int i = 1; i <= all; ++i) {
    if (zh[i] == kd) {
      if (!col[i]) {
        dfs(++cnt, i, 0);
      }
    }
  }
  if (cir == 1) {
    return;
  }
  memset(mat, 0, sizeof mat);
  for (int i = 1; i <= all; ++i) {
    if (zh[i] == kd) {
      for (int j = 0; j < e[i].size(); ++j) {
        int x = col[i], y = col[e[i][j]];
        ++mat[x][x];
        --mat[y][x];
      }
    }
  }
  (ans += det(cnt - 1)) %= mod;
}
int main() {
  n = read();
  m = read();
  mod = read();
  for (int i = 1; i <= n; ++i) {
    scanf("%s", s[i] + 1);
  }
  ++n;
  ++m;
  for (int i = 1; i < n; ++i) {
    for (int j = 1; j < m; ++j) {
      if (s[i][j] == '\\') {
        link(p, id(i, j), id(i + 1, j + 1));
      }
      if (s[i][j] == '/') {
        link(p, id(i, j + 1), id(i + 1, j));
      }
      if (s[i][j] == '*') {
        link(e, id(i, j), id(i + 1, j + 1));
        link(e, id(i, j + 1), id(i + 1, j));
      }
    }
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      zh[id(i, j)] = (i ^ j) & 1;
    }
  }
  calc(0);
  calc(1);
  ans = (ans + mod) % mod;
  printf("%lld\n", ans);
  close();
  return 0;
}
