#include using namespace std; typedef pair pii; typedef long long ll; const int N = 2000010, MOD = 998244353, INF = 0x3f3f3f3f; int n, m, w[N]; int e[N], ne[N], h[N], idx, p[N], d[N]; void add(int a, int b) { e[idx] = b, ne[idx] = h[a], h[a] = idx++; } void dfs(int r) { for (int i = h[r]; ~i; i = ne[i]) { int j = e[i]; if (j == p[r]) continue; p[j] = r, d[j] = d[r] - 1; dfs(j); } } int sum, v[N]; bool f[N]; set st[200010]; void ch(int x, int t, int g) { sum -= v[x] >= t; st[v[x]].erase({d[x], x}); v[x] += g; if (v[x] != t && f[x]) { f[x] = 0, v[x]--; ch(p[x], t, 1); } else if (v[x] == t - 1 && !f[x] && p[x]) { f[x] = 1, v[x]++; ch(p[x], t, -1); } st[v[x]].insert({d[x], x}); sum += v[x] >= t; } int main() { scanf("%d", &n); vector b(n); memset(h, -1, sizeof h); for (int i = 1, c, a; i < n + 1; i++) { scanf("%d", &c); while (c--) { scanf("%d", &a); if (b[a]) add(i, b[a]), add(b[a], i); else b[a] = i; } } dfs(1); sum = n - 1; st[0].insert({0, 1}); for (int i = 2; i < n + 1; i++) st[1].insert({d[i], i}), v[i] = f[i] = 1; printf("%d ", sum); for (int i = 2; i < n; i++) { sum -= st[i - 1].size(); vector t; for (auto u : st[i - 1]) t.push_back(u.second); for (auto u : t) if (v[u] == i - 1) ch(u, i, 0); printf("%d ", sum); } return 0; }