You have been given an integer $$N$$ and $$N$$ segments $$[L_i,R_i] \hspace{0.2cm} 1 \le i \le N $$. Now, we call a set of distinct integers $$ \{ k_1 , k_2,... , k_x \}, \hspace{0.2cm} 1 \le k_i \le N$$ good, if it is possible to arrange the integers in the set in some particular order to form a sequence $$ c_1, c_2 ... c_x $$, such that :
The Segment with index $$c_i $$ contains segment with index $$c_{i-1}, \forall \hspace{0.2cm} 2 \le i \le x $$. Segments are indexed by the order in which they appear in the input, beggining with $$1$$.
A segment $$[L_x,R_x]$$ is said to contain a segment $$[L_y,R_y]$$, if $$ L_x \le L_y $$ and $$ R_x \ge R_y $$. Now, for each $$j$$ from $$1$$ to $$N$$, you need find the number of good subsets of size $$j$$.
Print these numbers in increasing order of $$j$$. As these numbers can be rather large, print them Modulo $$998244353$$, a widely used prime.
Input Format :
The first line contains a single integer $$N$$. Each of the next $$N$$ lines contain $$2$$ space separated integers, where the $$2$$ integers on the $$i^{th}$$ line denote $$L_i,R_i $$.
Output Format
Print $$N$$ space separated integers. Note that all the integers need to be printed Modulo $$ 998244353 $$
Constraints :
$$ 1 \le N \le 3000 $$
$$ 1 \le L_i \le R_i \le 2 \cdot 10^9 $$
The good subsets of size $$ 1 $$ are $$ \{ 1 \} , \{ 2 \} , \{ 3 \} $$, and the good subsets of size $$ 2 $$ are $$ \{ 1,2 \} , \{ 2,3 \} $$
The subset $$ \{ 1,2 \} $$ is good since we can form the sequence $$ 2,1 $$, since segment with index $$1$$ from the input contains the segment with index $$2$$.
Similarily, the subset $$ \{ 2,3 \} $$ is good since we can arrange the integers to form the sequence $$ 2, 3 $$ since we know the segment with index $$3$$ from the input contains the segment with index $$2$$
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Login to unlock the editorial
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor