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

#BS0000238. Lịch đặt chỗ (My Calendar I)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Lịch đặt chỗ (My Calendar I)

My Calendar I

Source: LeetCode

Version: Phuoc Hung OJ Extended

Problem Statement

The calendar starts empty. Request ii reserves the half-open interval [si,ei)[s_i,e_i), including its start but excluding its end. Accept a request and store its interval exactly when it shares no time with an already accepted event. Rejecting a request leaves the calendar unchanged. Intervals touching only at an endpoint do not overlap. Process the qq requests in order.

Input

The first line contains integer qq. Each of the next qq lines contains integers si,eis_i,e_i, the start and end of request ii.

Output

Print qq lines in request order: YES for acceptance, NO for rejection.

Subtasks

  • Subtask 1 (20 points): 1≤q≤401\le q\le 40; 0≤si<ei≤1090\le s_i<e_i\le 10^9 for every 1≤i≤q1\le i\le q.
  • Subtask 2 (30 points): 1≤q≤10001\le q\le 1000; 0≤si<ei≤1090\le s_i<e_i\le 10^9 for all ii; si≤si+1s_i\le s_{i+1} for every 1≤i<q1\le i<q.
  • Subtask 3 (50 points): 1≤q≤10001\le q\le 1000; 0≤si<ei≤1090\le s_i<e_i\le 10^9 for every 1≤i≤q1\le i\le q.

Examples

Input

4
10 20
15 25
20 30
0 10

Output

YES
NO
YES
YES

Explanation

Store [10,20)[10,20). Reject [15,25)[15,25) because the intersection is [15,20)[15,20). Both [20,30)[20,30) and [0,10)[0,10) only touch endpoints of stored events, so accept them.