#include <bits/stdc++.h>
int mod;
int cnt = 0;
int matrix[305][305];
int mt(int a, int b) {
  if (b == 0) {
    return 1;
  }
  int c = mt(a, b >> 1);
  c = (long long)c * c % mod;
  if (b & 1) {
    c = (long long)c * a % mod;
  }
  return c;
}
int query() {
  long long ans = 1;
  for (int i = 1; i <= cnt; i++) {
    int j;
    for (j = i; j <= cnt; j++) {
      if (matrix[j][i]) {
        break;
      }
    }
    if (j > cnt) {
      return 0;
    }
    if (j > i) {
      ans = mod - ans;
      for (int k = i; k <= cnt; k++) {
        int t = matrix[i][k];
        matrix[i][k] = matrix[j][k];
        matrix[j][k] = t;
      }
    }
    ans = (long long)ans * matrix[i][i] % mod;
    int inv = mt(matrix[i][i], mod - 2);
    for (j = i; j <= cnt; j++) {
      matrix[i][j] = (long long)matrix[i][j] * inv % mod;
    }
    for (int j = i + 1; j <= cnt; j++) {
      for (int k = cnt; k >= i; k--) {
        matrix[j][k] -= (long long)matrix[i][k] * matrix[j][i] % mod;
        if (matrix[j][k] < 0) {
          matrix[j][k] += mod;
        }
      }
    }
  }
  return ans;
}
char s[105][105];
int id[105][105];
int fa[16384];
int tp[16384];
int findroot(int x) {
  if (fa[x] == x) {
    return x;
  }
  return fa[x] = findroot(fa[x]);
}
int main() {
  int n, m;
  scanf("%d%d%d", &n, &m, &mod);
  for (int i = 0; i < n; i++) {
    scanf("%s", s[i]);
  }
  int num = 0;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= m; j++) {
      num++;
      id[i][j] = num;
      fa[num] = num;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (s[i][j] == '/') {
        int x = findroot(id[i + 1][j]);
        int y = findroot(id[i][j + 1]);
        if (x == y) {
          printf("0\n");
          return 0;
        }
        fa[x] = y;
      } else if (s[i][j] == '\\') {
        int x = findroot(id[i][j]);
        int y = findroot(id[i + 1][j + 1]);
        if (x == y) {
          printf("0\n");
          return 0;
        }
        fa[x] = y;
      }
    }
  }
  int ans = 0;
  cnt = 0;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= m; j++) {
      if ((i + j) & 1) {
        if (fa[id[i][j]] == id[i][j]) {
          cnt++;
          tp[id[i][j]] = cnt;
        }
      }
    }
  }
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= m; j++) {
      if ((i + j) & 1) {
        tp[id[i][j]] = tp[findroot(id[i][j])];
      } else {
        tp[id[i][j]] = 0;
      }
    }
  }
  if (cnt <= 300) {
    for (int i = 0; i <= cnt; i++) {
      for (int j = 0; j <= cnt; j++) {
        matrix[i][j] = 0;
      }
    }
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        if (s[i][j] == '*') {
          int val0 = tp[id[i][j]];
          int val1 = tp[id[i + 1][j + 1]];
          if (!val0) {
            val0 = tp[id[i][j + 1]];
            val1 = tp[id[i + 1][j]];
          }
          matrix[val0][val0]++;
          if (matrix[val0][val0] >= mod) {
            matrix[val0][val0] -= mod;
          }
          matrix[val1][val1]++;
          if (matrix[val1][val1] >= mod) {
            matrix[val1][val1] -= mod;
          }
          matrix[val0][val1]--;
          if (matrix[val0][val1] < 0) {
            matrix[val0][val1] += mod;
          }
          matrix[val1][val0]--;
          if (matrix[val1][val0] < 0) {
            matrix[val1][val0] += mod;
          }
        }
      }
    }
    cnt--;
    ans += query();
    if (ans >= mod) {
      ans -= mod;
    }
  }
  cnt = 0;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= m; j++) {
      if (!((i + j) & 1)) {
        if (fa[id[i][j]] == id[i][j]) {
          cnt++;
          tp[id[i][j]] = cnt;
        }
      }
    }
  }
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= m; j++) {
      if (!((i + j) & 1)) {
        tp[id[i][j]] = tp[findroot(id[i][j])];
      } else {
        tp[id[i][j]] = 0;
      }
    }
  }
  if (cnt <= 300) {
    for (int i = 0; i <= cnt; i++) {
      for (int j = 0; j <= cnt; j++) {
        matrix[i][j] = 0;
      }
    }
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        if (s[i][j] == '*') {
          int val0 = tp[id[i][j]];
          int val1 = tp[id[i + 1][j + 1]];
          if (!val0) {
            val0 = tp[id[i][j + 1]];
            val1 = tp[id[i + 1][j]];
          }
          matrix[val0][val0]++;
          if (matrix[val0][val0] >= mod) {
            matrix[val0][val0] -= mod;
          }
          matrix[val1][val1]++;
          if (matrix[val1][val1] >= mod) {
            matrix[val1][val1] -= mod;
          }
          matrix[val0][val1]--;
          if (matrix[val0][val1] < 0) {
            matrix[val0][val1] += mod;
          }
          matrix[val1][val0]--;
          if (matrix[val1][val0] < 0) {
            matrix[val1][val0] += mod;
          }
        }
      }
    }
    cnt--;
    ans += query();
    if (ans >= mod) {
      ans -= mod;
    }
  }
  printf("%d\n", ans);
  return 0;
}
