#include <bits/stdc++.h>
using namespace std;
int n, lin, mod;
long long dp[502][502];
int main() {
  cin >> n >> lin >> mod;
  int col[503];
  memset(col, 0, sizeof col);
  for (int i = 1; i <= lin; ++i) {
    int nr1 = 0;
    for (int j = 1; j <= n; ++j) {
      char x;
      cin >> x;
      if (x == '1') {
        col[j]++;
        nr1++;
        if ((col[j] > 2) || (nr1 > 2)) {
          cout << 0 << "\n";
          return 0;
        }
      }
    }
    if (nr1 != 2) {
      cout << 0 << "\n";
      return 0;
    }
  }
  int nrl = 0;
  for (int i = 1; i <= n; ++i) {
    if (col[i] == 0) nrl++;
  }
  dp[lin][nrl] = 1;
  for (int i = lin; i < n; ++i) {
    for (int j = nrl; j >= 0; j--) {
      if (dp[i][j]) {
        int nr2 = 2 * i - (n - j);
        int nr1 = n - j - nr2;
        if (j >= 1)
          dp[i + 1][j - 1] =
              (dp[i + 1][j - 1] + 1LL * dp[i][j] * j % mod * nr1) % mod;
        if (j >= 2)
          dp[i + 1][j - 2] =
              (dp[i + 1][j - 2] + 1LL * j * (j - 1) / 2 % mod * dp[i][j]) % mod;
        dp[i + 1][j] =
            (dp[i + 1][j] + 1LL * nr1 * (nr1 - 1) / 2 % mod * dp[i][j]) % mod;
      }
    }
  }
  cout << dp[n][0] << "\n";
  return 0;
}
