cin >> n >> k; for (int i = 1; i <= n; ++i) for (int j = 0; j < N; ++j) cin >> a[i][j]; int M = (1 << N) - 1; for (int S = 0; S <= M; ++S) { vector<ll> V; int v = __builtin_popcount(S); if (v < k) continue; for (int i = 1; i <= n; ++i) { vector<int> A; for (int o = 0; o < N; ++o) if (S >> o & 1) A.push_back(a[i][o]); V.push_back(Hash(A)); } sort(V.begin(), V.end()); for (int i = 0, sz = V.size(), p = i; i < sz; i = p) { while (p < sz && V[p] == V[i]) ++p; f[v] += (ll) (p - i) * (p - i - 1) / 2; } } init_C(6); for (int i = k, t = 1; i <= N; ++i, t = -t) g[k] += t * C[i][k] * f[i]; cout << g[k] << "\n"; return0; }