#include <bits/stdc++.h>
using namespace std;
const int N = 405;
int n, m, mo, f[N * N], be[N * N], bs, x, y, ans;
int g[N][N];
vector<pair<int, int> > e[2];
string a;
int F(int x) { return x == f[x] ? x : f[x] = F(f[x]); }
int ksm(int x, int y) {
  int t = 1;
  for (; y; y >>= 1, x = (long long)x * x % mo)
    if (y & 1) t = (long long)t * x % mo;
  return t;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m >> mo;
  for (int i = 0, _e = ((n) * (m + 1) + (m)); i <= _e; ++i) f[i] = i;
  for (int i = 1, _e = n; i <= _e; ++i) {
    cin >> a;
    for (int j = 1, _e = m; j <= _e; ++j) {
      if (a[j - 1] == '*') {
        e[i + j & 1].push_back(pair<int, int>(((i - 1) * (m + 1) + (j - 1)),
                                              ((i) * (m + 1) + (j))));
        e[i + j + 1 & 1].push_back(pair<int, int>(((i) * (m + 1) + (j - 1)),
                                                  ((i - 1) * (m + 1) + (j))));
      } else {
        if (a[j - 1] == '\\')
          x = F(((i - 1) * (m + 1) + (j - 1))), y = F(((i) * (m + 1) + (j)));
        else
          x = F(((i - 1) * (m + 1) + (j))), y = ((i) * (m + 1) + (j - 1));
        if (x == y) return puts("0"), 0;
        f[x] = y;
      }
    }
  }
  for (int o = 0, _e = 1; o <= _e; ++o) {
    bs = 0;
    memset(g, 0, sizeof g);
    for (int i = 0, _e = n; i <= _e; ++i)
      for (int j = 0, _e = m; j <= _e; ++j)
        if ((i + j & 1) == o &&
            F(((i) * (m + 1) + (j))) == ((i) * (m + 1) + (j)))
          be[((i) * (m + 1) + (j))] = ++bs;
    for (auto i : e[o]) {
      x = F(i.first);
      y = F(i.second);
      if (x != y)
        --g[be[x]][be[y]], --g[be[y]][be[x]], ++g[be[x]][be[x]],
            ++g[be[y]][be[y]];
    }
    for (int i = 1, _e = bs; i <= _e; ++i)
      for (int j = 1, _e = bs; j <= _e; ++j) g[i][j] %= mo;
    int cnt = 1;
    for (int i = 1, _e = bs - 1; i <= _e; ++i) {
      if (!g[i][i])
        for (int j = i + 1, _e = bs - 1; j <= _e; ++j)
          if (g[j][i]) {
            swap(g[i], g[j]);
            cnt = -cnt;
            break;
          }
      cnt = (long long)cnt * g[i][i] % mo;
      if (!cnt) break;
      int iv = ksm(g[i][i], mo - 2);
      for (int j = i + 1, _e = bs - 1; j <= _e; ++j)
        if (g[j][i]) {
          int ny = (long long)iv * g[j][i] % mo;
          for (int k = i + 1, _e = bs - 1; k <= _e; ++k)
            g[j][k] = (-(long long)ny * g[i][k] + g[j][k]) % mo;
        }
    }
    ans = (ans + cnt + mo) % mo;
  }
  cout << ans;
}
