func_code_string: #include <bits/stdc++.h>   using namespace std;   const int INF = 0x3fffffff;   const int SINF = 0x7fffffff;   const long long LINF = 0x3fffffffffffffff;   const long long SLINF = 0x7fffffffffffffff;   const int MAXN = 30007;   const int MAXD = 6;   const int MOD = 998244353;   int n, d;   int a[MAXN][MAXD][MAXD];   int tmp[MAXD][MAXD];   int ans[MAXN];   int m1[MAXN], m2[MAXN];   map<vector<int>, int> mp;   map<vector<int>, int>::iterator it;   void init();   void input();   void work();   vector<int> gauss(int a[][MAXD]);   int add(int x, int y) {     x += y;     if (x >= MOD) x -= MOD;     return x;   }   void addv(int &x, int y) {     x += y;     if (x >= MOD) x -= MOD;   }   int dec(int x, int y) {     x -= y;     if (x < 0) x += MOD;     return x;   }   void decv(int &x, int y) {     x -= y;     if (x < 0) x += MOD;   }   int qpow(int a, int b) {     long long base = a, ans = 1;     while (b) {       if (b & 1) (ans *= base) %= MOD;       (base *= base) %= MOD;       b >>= 1;     }     return static_cast<int>(ans);   }   int main() {     init();     input();     work();   }   void init() { ios::sync_with_stdio(false); }   void input() {     scanf( %d%d , &n, &d);     int nk;     for (int i = 1; i <= n; ++i) {       scanf( %d , &nk);       for (int j = 1; j <= nk; ++j) {         for (int k = 1; k <= d; ++k) scanf( %d , &a[i][j][k]);       }     }   }   void work() {     int kc = 0;     vector<int> v;     for (int i = 1; i <= n; ++i) {       v = gauss(a[i]);       if ((it = mp.find(v)) == mp.end())         mp[v] = ans[i] = ++kc;       else         ans[i] = it->second;     }     for (int i = 1; i <= n; ++i) printf( %d  , ans[i]);     putchar(  n );   }   vector<int> gauss(int a[][MAXD]) {     for (int i = 1; i <= d; ++i) m1[i] = m2[i] = 0;     for (int i = 1; i <= d; ++i)       for (int j = 1; j <= d; ++j) tmp[i][j] = (a[i][j] + MOD) % MOD;     long long g;     int ni = 1;     for (int i = 1; i <= d; ++i) {       for (int j = ni; j <= d; ++j) {         if (tmp[j][i]) {           for (int k = 1; k <= d; ++k) swap(tmp[ni][k], tmp[j][k]);         }       }       if (tmp[ni][i]) {         m1[ni] = i, m2[i] = ni;         for (int j = ni + 1; j <= d; ++j) {           g = qpow(tmp[ni][i], MOD - 2) * static_cast<long long>(tmp[j][i]) % MOD;           for (int k = i; k <= d; ++k) decv(tmp[j][k], g * tmp[ni][k] % MOD);         }         ++ni;       }     }     for (int i = ni - 1; i > 0; --i) {       for (int j = m1[i] + 1; j <= d; ++j) {         if (m2[j]) {           g = qpow(tmp[m2[j]][j], MOD - 2) * static_cast<long long>(tmp[i][j]) %               MOD;           for (int k = j; k <= d; ++k) decv(tmp[i][k], tmp[m2[j]][k] * g % MOD);         }       }     }     for (int i = 1; i < ni; ++i) {       g = qpow(tmp[i][m1[i]], MOD - 2);       for (int j = m1[i]; j <= d; ++j)         tmp[i][j] = static_cast<long long>(tmp[i][j]) * g % MOD;     }     vector<int> ans;     for (int i = 1; i < ni; ++i)       for (int j = 1; j <= d; ++j) ans.push_back(tmp[i][j]);     return ans;   }   