#279. CS240 project Problem 4

CS240 project Problem 4

Description

You are asked to hold a conference, the first step of which is to choose the proper dates. The conference must span several consecutive days. Each day, one lecturer is needed to give a presentation, and each lecturer cannot give more than one presentation during the conference. There are nn lecturers that can participate in the conference in total, the ith of whom is available from day lil_i to day rir_i, inclusive of lil_i and rir_i. Several consecutive days can be chosen to hold the conference if there is a way to invite available lecturers to each of the days, without inviting lecturers more than once. For kk from 11 to nn, we want to find out how many ways are there to choose kk consecutive days as the conference dates.

Format

Input

The first line of input contains one integer n, indicating the number of lecturers (1n1×1041 \leq n \leq 1 \times 10^4). Each of the next n lines contains two integers lil_i and rir_i, the ithi_{th} lecturer is available during these days (1liri2×1041 \leq li \leq ri \leq 2 × 10^4).

Output

Print nn lines, the kthk_{th} line contains one integer indicating the number of ways of selecting a conference of kk days.

Samples

3
1 3
2 4
3 6
6
4
3

Explanation

k = 1: all the days are valid, so there are 6 ways. k = 2: [1, 2], [2, 3], [3, 4], [4, 5] are valid, [5, 6] is not valid, so there are 4 ways. k = 3: [1, 3], [2, 4], [3, 5] are valid, 3 ways.

5
1 3
1 3
1 3
1 3
1 3
3
2
1
0
0

Explanation

k = 1: all the days are valid, so there are 6 ways. k = 2: [1, 2], [2, 3], [3, 4], [4, 5] are valid, [5, 6] is not valid, so there are 4 ways. k = 3: [1, 3], [2, 4], [3, 5] are valid, 3 ways.

Limitation

1s, 256MB for test cases with n<100n < 100 10s, 4096MB for the others