#include <bits/stdc++.h>
using namespace std;
const int maxn = 405;
const int maxm = 50005;
int cnt, p[maxm], id[maxn][maxn];
int tot, bel[maxm];
char g[maxn][maxn];
int n, m, mod, a[maxn][maxn];
int findp(int t) { return p[t] ? p[t] = findp(p[t]) : t; }
void merge(int u, int v) {
  u = findp(u);
  v = findp(v);
  if (u != v) p[u] = v;
}
long long fpm(long long p, long long k) {
  long long res = 1ll;
  while (k) {
    if (k & 1) (res *= p) %= mod;
    (p *= p) %= mod;
    k >>= 1;
  }
  return res;
}
int gauss(int n) {
  int res = 1;
  for (int i = 1; i <= n; i++) {
    int t = i;
    while (t <= n && !a[t][i]) ++t;
    if (t > n) return 0;
    if (t != i)
      for (int j = 1; j <= n; j++) swap(a[t][j], a[i][j]);
    int inc = fpm(a[i][i], mod - 2);
    for (int j = i + 1; j <= n; j++) {
      int o = (long long)a[j][i] * inc % mod;
      for (int k = 1; k <= n; k++)
        a[j][k] = (a[j][k] - (long long)o * a[i][k]) % mod;
    }
    if (t != i) res *= -1;
    res = (long long)res * a[i][i] % mod;
  }
  return res;
}
void add(int u, int v) {
  u = findp(u);
  u = bel[u];
  v = findp(v);
  v = bel[v];
  if (u == v) return;
  a[u][u]++;
  a[v][v]++;
  a[u][v]--;
  a[v][u]--;
}
int solve(int bit) {
  memset(a, 0, sizeof a);
  tot = 0;
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= m; j++)
      if ((i + j & 1) == bit && !p[id[i][j]]) bel[id[i][j]] = ++tot;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      if (g[i][j] == '*') {
        if ((i + j & 1) == bit)
          add(id[i - 1][j - 1], id[i][j]);
        else
          add(id[i - 1][j], id[i][j - 1]);
      }
  return gauss(tot - 1);
}
int main() {
  scanf("%d %d %d", &n, &m, &mod);
  for (int i = 1; i <= n; i++) scanf("%s", g[i] + 1);
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= m; j++) id[i][j] = ++cnt;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      if (g[i][j] != '*') {
        if (g[i][j] == '/')
          merge(id[i - 1][j], id[i][j - 1]);
        else
          merge(id[i - 1][j - 1], id[i][j]);
      }
  int ans = (solve(1) + solve(0)) % mod;
  printf("%d", ans < 0 ? ans + mod : ans);
  return 0;
}
