#include <bits/stdc++.h>
using namespace std;
int p;
inline int mod(int x) { return x >= p ? x - p : x; }
inline int calc(int x, int y) {
  int z = 1;
  for (; y; x = (long long)x * x % p, y >>= 1)
    if (y & 1) z = (long long)x * z % p;
  return z;
}
char c[202][202];
int a[202][202], d[202][202], i, j, k, m, n, q, s, x, y, z;
void dfs(int u, int v) {
  a[u][v] = s;
  if (u && v && c[u - 1][v - 1] == 92 && !a[u - 1][v - 1]) dfs(u - 1, v - 1);
  if (u < n && v < m && c[u][v] == 92 && !a[u + 1][v + 1]) dfs(u + 1, v + 1);
  if (u && v < m && c[u - 1][v] == 47 && !a[u - 1][v + 1]) dfs(u - 1, v + 1);
  if (u < n && v && c[u][v - 1] == 47 && !a[u + 1][v - 1]) dfs(u + 1, v - 1);
}
inline void solve() {
  for (i = x = 1; i < s; i++) {
    for (j = i; j < s && !d[i][i]; j++)
      if (d[j][i]) swap(d[i], d[j]), x = mod(p - x);
    for (x = (long long)x * d[j = i][i] % p, z = calc(d[i][i], p - 2); j < s;
         j++)
      d[i][j] = (long long)d[i][j] * z % p;
    for (j = i + 1; j < s; j++)
      if (d[j][i])
        for (z = mod(p - d[j][k = i]); k < s; k++)
          d[j][k] = (d[j][k] + (long long)d[i][k] * z) % p;
  }
  for (int i = 1; i <= s; i++)
    for (int j = 1; j <= s; j++) d[i][j] = 0;
}
int u, v;
inline void build(int w) {
  for (i = 0; i <= n; i++)
    for (j = 0; j <= m; j++)
      if (((i ^ j ^ w) & 1) && !a[i][j]) s++, dfs(i, j);
  for (i = 0; i < n; i++)
    for (j = 0; j < m; j++)
      if (c[i][j] == '*')
        if (((i ^ j ^ w) & 1) && a[i][j] != a[i + 1][j + 1])
          u = a[i][j], v = a[i + 1][j + 1], d[u][u] = mod(d[u][u] + 1),
          d[v][v] = mod(d[v][v] + 1), d[u][v] = mod(p + d[u][v] - 1),
          d[v][u] = mod(p + d[v][u] - 1);
        else if ((~(i ^ j ^ w) & 1) && a[i + 1][j] != a[i][j + 1])
          u = a[i + 1][j], v = a[i][j + 1], d[u][u] = mod(d[u][u] + 1),
          d[v][v] = mod(d[v][v] + 1), d[u][v] = mod(p + d[u][v] - 1),
          d[v][u] = mod(p + d[v][u] - 1);
}
int main() {
  scanf("%d%d%d", &n, &m, &p);
  for (i = 0; i < n; i++) scanf("%s", c[i]);
  build(0), solve(), y = x, s = x = 0, build(1), solve(),
                     printf("%d\n", mod(x + y));
  return 0;
}
