func_code_string: #include <bits/stdc++.h>   using namespace std;   double safe_sqrt(double x) { return sqrt(max((double)0.0, x)); }   long long GI(long long& x) { return scanf( %lld , &x); }   const long long MOD = 1e9 + 7;   const long long MN = 1000111;   long long gt[MN];   vector<long long> h[MN];   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout << (fixed) << setprecision(9);     const long long MOD = 1e9 + 7;     gt[0] = 1;     for (long long i = (1), _b = (MN - 1); i <= _b; ++i)       gt[i] = gt[i - 1] * i % MOD;     long long n, m;     while (GI(n) == 1 && GI(m) == 1) {       for (long long i = (1), _b = (m); i <= _b; ++i) h[i].clear();       for (long long i = (1), _b = (n); i <= _b; ++i) {         long long k;         GI(k);         while (k--) {           long long u;           GI(u);           h[u].push_back(i);         }       }       sort(h + 1, h + m + 1);       long long i = 1;       long long res = 1;       while (i <= m) {         long long j = i;         while (j < m && h[j + 1] == h[i]) j++;         res = res * gt[j - i + 1] % MOD;         i = j + 1;       }       cout << res << endl;     }   }   