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

#CC0000083. Lịch hẹn trùng nhau nhiều nhất (My Calendar III)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Lịch hẹn trùng nhau nhiều nhất (My Calendar III)

My Calendar III

Source: LeetCode

Version: Phuoc Hung OJ Extended

Problem Statement

An initially empty calendar receives qq bookings. Booking ii occupies the half-open interval [li,ri)[l_i,r_i). After each booking, report the largest number of simultaneous overlapping bookings seen so far.

Input

The first line contains qq, followed by qq lines li,ril_i,r_i in booking order. This is the stdin/stdout adaptation.

Output

Print qq lines; line ii gives the maximum number of overlapping bookings after the ii-th insertion.

Subtasks

  • Subtask 1 (20 points): 1≤q≤201\le q\le 20; 0≤li<ri≤1090\le l_i<r_i\le10^9.
  • Subtask 2 (30 points): 1≤q≤1201\le q\le 120; 0≤li<ri≤1090\le l_i<r_i\le10^9.
  • Subtask 3 (50 points): 1≤q≤4001\le q\le 400; 0≤li<ri≤1090\le l_i<r_i\le10^9.

Examples

Input

6
10 20
50 60
10 40
5 15
5 10
25 55

Output

1
1
2
3
3
3

Explanation

The first two bookings do not overlap. Adding [10,40)[10,40) yields a maximum overlap of 22. Adding [5,15)[5,15) raises it to 33 on [10,15)[10,15). Later bookings keep the maximum at 33.