Under construction

Still being built. Things may change

Sum of Intersection Sizes

Time limit4sMemory limit1024 MB

Summary
Given N integer intervals, find for each k the sum of intersection sizes over all k-subsets of intervals, modulo 998244353.
Level

Medium6 of 10

Topics
Combinatorics, Sorting, Math
Solved
No attempts yet

Problem

You are given NN sets S1,S2,⋯ ,SNS_1, S_2, \cdots, S_N. Each SiS_i is the set of all integers from lil_i to rir_i, inclusive.

For each kk, choose kk of the sets 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 make the choice. 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 998244353. 998244353 is a prime.

Input

The first line contains an integer NN. (1≤N≤3000001 \leq N \leq 300000)

Each of the next NN lines contains two integers lil_i and rir_i, separated by a space, which describe SiS_i. (1≤li≤ri≤9982443521 \leq l_i \leq r_i \leq 998244352)

Output

Print NN lines. For every 1≤k≤N1 \leq k \leq N, print aka_k modulo 998244353 on the kk-th line.

Examples1

  1. Example 1

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