#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 10, MN = 505;
int mod, n, m;
void ok(int &x) {
  if (x >= mod) x -= mod;
}
int bpw(int a, int b) {
  if (!b) return 1;
  int t = bpw(a, b / 2);
  t = 1ll * t * t % mod;
  if (b & 1) return 1ll * a * t % mod;
  return t;
}
struct mat {
  int sz;
  int a[MN][MN];
  mat() { memset(a, 0, sizeof a), sz = 0; }
  void out() {
    for (int i = 0; i < sz; ++i) {
      for (int j = 0; j < sz; ++j) cout << a[i][j] << ' ';
      cout << '\n';
    }
    cout << "----------\n";
  }
  int det() {
    for (int i = 0; i < MN; ++i)
      for (int j = 0; j < MN; ++j) {
        while (a[i][j] < 0) a[i][j] += mod;
      }
    int ret = 1;
    for (int i = 0; i < sz; ++i) {
      for (int j = i + 1; j < sz; ++j)
        if (a[j][i]) {
          for (int l = 0; l < sz; ++l) swap(a[j][l], a[i][l]);
          ret = mod - ret;
          ok(ret);
          break;
        }
      if (a[i][i] == 0) return 0;
      int t = bpw(a[i][i], mod - 2);
      ret = 1ll * ret * bpw(t, mod - 2) % mod;
      for (int j = i; j < sz; ++j) a[i][j] = 1ll * a[i][j] * t % mod;
      for (int j = i + 1; j < sz; ++j)
        if (a[j][i]) {
          int x = a[j][i];
          for (int l = i; l < sz; ++l) {
            a[j][l] = a[j][l] + mod - 1ll * x * a[i][l] % mod;
            ok(a[j][l]);
          }
        }
    }
    return ret;
  }
} A[2];
string s[MN];
int col[MN][MN];
bool mk[MN][MN];
bool valid(int r, int c) { return r + 1 && c + 1 && n - r && m - c; }
void dfs(int r, int c, int C) {
  col[r][c] = C;
  mk[r][c] = true;
  if (valid(r, c) && s[r][c] == '\\' && !mk[r + 1][c + 1]) dfs(r + 1, c + 1, C);
  if (valid(r, c - 1) && s[r][c - 1] == '/' && !mk[r + 1][c - 1])
    dfs(r + 1, c - 1, C);
  if (valid(r - 1, c - 1) && s[r - 1][c - 1] == '\\' && !mk[r - 1][c - 1])
    dfs(r - 1, c - 1, C);
  if (valid(r - 1, c) && s[r - 1][c] == '/' && !mk[r - 1][c + 1])
    dfs(r - 1, c + 1, C);
}
int main() {
  ios_base ::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n >> m >> mod;
  for (int i = 0; i < n; ++i) cin >> s[i];
  for (int i = 0; i <= n; ++i)
    for (int j = 0; j <= m; ++j)
      if (!mk[i][j]) dfs(i, j, A[(i + j) % 2].sz++);
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j)
      if (s[i][j] == '*') {
        int x = col[i][j], y = col[i + 1][j + 1];
        A[(i + j) % 2].a[x][y]--, A[(i + j) % 2].a[y][x]--;
        A[(i + j) % 2].a[x][x]++, A[(i + j) % 2].a[y][y]++;
        x = col[i][j + 1], y = col[i + 1][j];
        A[1 - (i + j) % 2].a[x][y]--, A[1 - (i + j) % 2].a[y][x]--;
        A[1 - (i + j) % 2].a[x][x]++, A[1 - (i + j) % 2].a[y][y]++;
      }
  A[0].sz--, A[1].sz--;
  cout << (A[0].det() + A[1].det()) % mod << '\n';
  return 0;
}
