#include <bits/stdc++.h>   using namespace std;   int cf[45], nc[45];   vector<int> ppf[45];   bool canadd(int i, int m) {     for (int p : ppf[m]) {       if (nc[p] && cf[p] != i % p) return false;     }     return true;   }   void add(int i, int m) {     for (int p : ppf[m]) {       if (nc[p] == 0) cf[p] = i % p;       nc[p]++;     }   }   void rem(int m) {     for (int p : ppf[m]) {       nc[p]--;     }   }   vector<pair<int, int> > loc[100005];   int k[100005];   int n, m;   int main() {     for (int i = (2); i < (45); i++) {       int x = i;       for (int j = (2); j < (45); j++) {         int fct = 1;         while (x % j == 0) {           fct *= j;           ppf[i].push_back(fct);           x /= j;         }       }     }     scanf( %d %d , &n, &m);     for (int i = (0); i < (n); i++) {       scanf( %d , k + i);       for (int j = (0); j < (k[i]); j++) {         int x;         scanf( %d , &x);         loc[x].push_back(make_pair(i, j));       }     }     for (int x = (1); x < (m + 1); x++) {       queue<pair<int, int> > cq;       int prv = -1, ans = 0;       for (auto l : loc[x]) {         int i, j;         tie(i, j) = l;         if (i != prv + 1) {           while (int(cq.size())) {             int fi, fj;             tie(fi, fj) = cq.front();             cq.pop();             rem(k[fi]);           }         }         while (!canadd(j, k[i])) {           int fi, fj;           tie(fi, fj) = cq.front();           cq.pop();           rem(k[fi]);         }         add(j, k[i]);         cq.emplace(i, j);         prv = i;         ans = max(ans, int(cq.size()));       }       while (int(cq.size())) {         int fi, fj;         tie(fi, fj) = cq.front();         cq.pop();         rem(k[fi]);       }       printf( %d n , ans);     }   }   