#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void chkmin(T &a, T b) {
  if (a > b) a = b;
}
template <class T>
inline void chkmax(T &a, T b) {
  if (a < b) a = b;
}
inline void myassert(bool a, string s) {
  if (!a) cerr << s << endl, exit(0);
}
inline int read() {
  int s = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch) && ch != '-') ch = getchar();
  if (ch == '-') ch = getchar(), f = -1;
  while (isdigit(ch)) s = s * 10 + ch - '0', ch = getchar();
  return ~f ? s : -s;
}
const int maxn = 400 + 20;
int n, m, mod;
inline int power(int a, int b) {
  int ans = 1;
  while (b) {
    if (b & 1) ans = (long long)ans * a % mod;
    b >>= 1;
    a = (long long)a * a % mod;
  }
  return ans;
}
char str[maxn][maxn];
int num[maxn][maxn], tot;
int fa[maxn * maxn], to[maxn * maxn], ntot;
int fin(int x) { return x == fa[x] ? x : fa[x] = fin(fa[x]); }
inline void merge(int x, int y) {
  x = fin(x);
  y = fin(y);
  fa[y] = x;
}
inline void init() {
  n = read();
  m = read();
  mod = read();
  for (int i = (1), _end_ = (n); i <= _end_; i++) scanf("%s", str[i] + 1);
  for (int i = (0), _end_ = (n); i <= _end_; i++)
    for (int j = (0), _end_ = (m); j <= _end_; j++)
      num[i][j] = ++tot, fa[tot] = tot;
  for (int i = (1), _end_ = (n); i <= _end_; i++)
    for (int j = (1), _end_ = (m); j <= _end_; j++) {
      if (str[i][j] == '/')
        merge(num[i - 1][j], num[i][j - 1]);
      else if (str[i][j] == '\\')
        merge(num[i - 1][j - 1], num[i][j]);
    }
}
inline int Det(int n, int A[maxn][maxn]) {
  int ans = 1;
  for (int i = (1), _end_ = (n); i <= _end_; i++)
    for (int j = (1), _end_ = (n); j <= _end_; j++) A[i][j] %= mod;
  for (int i = (1), _end_ = (n); i <= _end_; i++) {
    if (!A[i][i]) {
      for (int j = (i + 1), _end_ = (n); j <= _end_; j++) {
        if (A[j][i]) {
          for (int l = (i), _end_ = (n); l <= _end_; l++)
            swap(A[i][l], A[j][l]);
          ans = -ans;
        }
      }
    }
    int inv = power((A[i][i] + mod) % mod, mod - 2);
    for (int j = (i + 1), _end_ = (n); j <= _end_; j++) {
      int t = (long long)A[j][i] * inv % mod;
      for (int l = (i), _end_ = (n); l <= _end_; l++)
        A[j][l] = (A[j][l] - (long long)t * A[i][l]) % mod;
    }
    ans = (long long)ans * A[i][i] % mod;
  }
  ans = (ans + mod) % mod;
  return ans;
}
int A[maxn][maxn];
int ans;
inline void doing() {
  ntot = 0;
  for (int i = (0), _end_ = (n); i <= _end_; i++)
    for (int j = (0), _end_ = (m); j <= _end_; j++)
      if (i + j & 1) {
        int x = fin(num[i][j]);
        if (!to[x]) to[x] = ++ntot;
      }
  memset(A, 0, sizeof(A));
  for (int i = (1), _end_ = (n); i <= _end_; i++)
    for (int j = (1), _end_ = (m); j <= _end_; j++)
      if (str[i][j] == '*') {
        int x, y;
        if (i + j & 1)
          x = to[fin(num[i - 1][j - 1])], y = to[fin(num[i][j])];
        else
          x = to[fin(num[i][j - 1])], y = to[fin(num[i - 1][j])];
        A[x][y]--;
        A[y][x]--;
        A[x][x]++;
        A[y][y]++;
      }
  ans = (ans + Det(ntot - 1, A)) % mod;
  ntot = 0;
  memset(to, 0, sizeof(to));
  for (int i = (0), _end_ = (n); i <= _end_; i++)
    for (int j = (0), _end_ = (m); j <= _end_; j++)
      if (~i + j & 1) {
        int x = fin(num[i][j]);
        if (!to[x]) to[x] = ++ntot;
      }
  memset(A, 0, sizeof(A));
  for (int i = (1), _end_ = (n); i <= _end_; i++)
    for (int j = (1), _end_ = (m); j <= _end_; j++)
      if (str[i][j] == '*') {
        int x, y;
        if (~i + j & 1)
          x = to[fin(num[i - 1][j - 1])], y = to[fin(num[i][j])];
        else
          x = to[fin(num[i][j - 1])], y = to[fin(num[i - 1][j])];
        assert(0 < x && x <= ntot);
        assert(0 < y && y <= ntot);
        A[x][y]--;
        A[y][x]--;
        A[x][x]++;
        A[y][y]++;
      }
  ans = (ans + Det(ntot - 1, A)) % mod;
  printf("%d\n", ans);
}
int main() {
  init();
  doing();
  return 0;
}
