#include #include #define rep(i,n) for (int i = 0; i < (n); ++i) #define repp(i,n,m) for (int i = m; i < (n); ++i) using namespace std; using namespace atcoder; using namespace internal; using ll = long long; using P = pair; template void rev(vector &ar){reverse(ar.begin(),ar.end());} const int maxsize = 5000; using pbv = pair,vector>; typedef bitset bset; int popcount(bset &a, int n){ int ans = 0; rep(i,n) if(a.test(i)) ans++; return ans; } int ten(vector &a, int m){ rev(a); int ans = 0; rep(i,m){ ans += a[i]; if (i != m-1) ans *= 2; } return ans; } struct vs{ vector to; vector from; int cases; }; int main(){ bset bm(0); bm.set(); int n, m; cin >> n >> m; int rui = 1<> ar(n,vector(m)); rep(i,n) rep(j,m) cin >> ar[i][j]; vector b(m,0); rep(i,m){ rep(j,n){ if (ar[j][i] == 1) b[i].set(j); } } vector popc(rui); queue que; que.push(pbv(bm,{})); while (!que.empty()){ pbv p = que.front(); que.pop(); bset x = p.first; vector c = p.second; int s = c.size(); if (s == m){ int pos = ten(c,m); int cnt = popcount(x,n); popc[pos] = cnt; } else { c.emplace_back(0); que.push(pbv(x,c)); c[s] = 1; x &= b[s]; que.push(pbv(x,c)); } } vector dp(rui); rep(i,rui) dp[i].cases = 0; rep(i,rui){ rep(j,m){ if (~i >> j & 1){ int t = i|1<