PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#PS0000254. Trò chơi trực tuyến (Online Games)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Trò chơi trực tuyến (Online Games)

Online Games

Source: AtCoder

Version: Phuoc Hung OJ Extended

Problem Statement

Player ii of an online game logs in on exactly BiB_i consecutive days starting on day AiA_i, and on no other days. For each k=1,2,…,Nk=1,2,\ldots,N, count the days with exactly kk active players.

Input

First line: NN. The next NN lines contain Ai,BiA_i,B_i.

Output

Print NN integers D1,…,DND_1,\ldots,D_N on one line, where DkD_k counts days with exactly kk active players.

Subtasks

  • Subtask 1 (20 points): 1≤N≤1001\le N\le 100; 1≤Ai,Bi≤1001\le A_i,B_i\le 100.
  • Subtask 2 (30 points): 1≤N≤2000001\le N\le 200000; 1≤Ai,Bi≤10000000001\le A_i,B_i\le 1000000000; Ai=A1A_i=A_1.
  • Subtask 3 (50 points): 1≤N≤2000001\le N\le 200000; 1≤Ai,Bi≤10000000001\le A_i,B_i\le 1000000000.

Example 1

Input

3
1 2
2 3
3 1

Output

2 2 0

Explanation

Days 1 and 4 have one player, days 2 and 3 have two; none has three.

Example 2

Input

2
1000000000 1000000000
1000000000 1000000000

Output

0 1000000000

Explanation

Both players share the same billion-day interval.