Under construction

Still being built. Things may change

Sum of Intersection Sizes

Interview

Time limit4sMemory limit1024 MB

Summary
Given N sets, find for each k the sum of intersection sizes over all ways to pick k of the sets, modulo 998244353.
Level

Medium5 of 10

Topics
Combinatorics, Hash map
Solved
No attempts yet

Problem

You are given NN sets S1,S2,⋯ ,SNS_1, S_2, \cdots, S_N.

For each kk, choose kk of the sets among S1,S2,⋯ ,SNS_1, S_2, \cdots, S_N and take the size of their intersection. aka_k is the sum of these intersection sizes over all (Nk){N \choose k} ways to choose the sets. In formula form:

ak:=∑τ⊆{1,2,⋯,N}∣τ∣=k∣⋂i∈τSi∣.a_{k} := \sum_{\substack{\tau \subseteq \{1, 2, \cdots, N\} \\ |\tau|=k}} \left|\bigcap_{i \in \tau} S_{i}\right|.

For every k=1,2,⋯ ,Nk=1, 2, \cdots, N, find aka_{k} modulo 998 244 353998\,244\,353 (=119×223+1)(=119 \times 2^{23}+1). 998 244 353998\,244\,353 is prime.

Input

The first line contains an integer NN. (1≤N≤1 000 0001\leq N\leq 1\,000\,000)

The next NN lines describe the sets. The ii-th of these lines contains space-separated integers in the following format.

  • The first number is ∣Si∣|S_i|. (∣Si∣≥1|S_i|\ge 1)
  • The next ∣Si∣|S_i| numbers are the elements of SiS_i, Si,1,Si,2,⋯ ,Si,∣Si∣S_{i,1}, S_{i,2}, \cdots, S_{i,|S_i|}, given in ascending order. (1≤Si,j≤1091\le S_{i,j}\le 10^9)

The sum of all set sizes does not exceed 1 000 0001\,000\,000. That is, ∑1≤i≤N∣Si∣≤1 000 000\sum_{1\leq i\leq N}|S_{i}|\leq 1\,000\,000.

Output

Print NN lines. On line kk, print aka_{k} modulo 998 244 353998\,244\,353 for each 1≤k≤N1 \leq k \leq N.

Examples1

  1. Example 1

    Input
    3
    2 1 2
    2 2 3
    3 1 2 3
    
    Expected output
    7
    5
    1