func_code_string: #include <bits/stdc++.h>   using namespace std;   int n, m, zero, one, tot;   long long mod;   long long dp[505][505];   string str[505];   long long dfs(int z, int o) {     long long& ret = dp[z][o];     if (ret != -1) return ret;     ret = 0;     if (z == 0 && o == 0) return ret = 1;     if (z > 0 && o > 0) {       long long nxt = dfs(z - 1, o);       nxt = nxt * (long long)z % mod;       nxt = nxt * (long long)o % mod;       ret = (ret + nxt) % mod;     }     if (z > 1) {       long long nxt = dfs(z - 2, o + 2);       nxt = nxt * (long long)z * (z - 1) / 2 % mod;       ret = (ret + nxt) % mod;     }     if (o > 1) {       long long nxt = dfs(z, o - 2);       nxt = nxt * (long long)o * (o - 1) / 2 % mod;       ret = (ret + nxt) % mod;     }     return ret;   }   int main() {     scanf( %d %d %I64d , &n, &m, &mod);     int flag = 0;     for (int i = 0; i < m; i++) {       cin >> str[i];       int cnt = 0;       for (int j = 0; j < n; j++) {         if (str[i][j] ==  1 ) ++cnt;       }       if (cnt != 2) {         flag = 1;       }     }     if (flag) {       puts( 0 );       return 0;     }     for (int j = 0; j < n; j++) {       int cc = 0;       for (int i = 0; i < m; i++) {         if (str[i][j] ==  1 ) ++cc;       }       if (cc >= 3) {         puts( 0 );         return 0;       }       if (cc == 0)         zero++;       else if (cc == 1)         one++;     }     if (zero + zero + one != 2 * (n - m)) {       puts( 0 );       return 0;     }     memset(dp, -1, sizeof(dp));     long long ans = dfs(zero, one);     cout << ans;   }   