New Year and Conference

각 강연이 두 장소 a와 b에서 서로 다른 시간 구간을 가질 때, 한 장소에서는 겹치지 않지만 다른 장소에서는 겹치는 부분집합이 존재하는지 판정한다.

어려움8정렬이분 탐색구간구현아직 제출이 없습니다시간 제한2초메모리 제한1024 MB

문제

Filled with optimism, Hyunuk will host a conference about how great this new year will be!

The conference will have nn lectures. Hyunuk has two candidate venues aa and bb. For each of the nn lectures, the speaker specified two time intervals \[sa_i,ea_i]\[sa\_i, ea\_i] (sa_iea_isa\_i \le ea\_i) and \[sb_i,eb_i]\[sb\_i, eb\_i] (sb_ieb_isb\_i \le eb\_i). If the conference is situated in venue aa, the lecture will be held from sa_isa\_i to ea_iea\_i, and if the conference is situated in venue bb, the lecture will be held from sb_isb\_i to eb_ieb\_i. Hyunuk will choose one of these venues and all lectures will be held at that venue.

Two lectures are said to overlap if they share any point in time in common. Formally, a lecture held in interval \[x,y]\[x, y] overlaps with a lecture held in interval \[u,v]\[u, v] if and only if max(x,u)min(y,v)\max(x, u) \le \min(y, v).

We say that a participant can attend a subset ss of the lectures if the lectures in ss do not pairwise overlap (i.e. no two lectures overlap). Note that the possibility of attending may depend on whether Hyunuk selected venue aa or venue bb to hold the conference.

A subset of lectures ss is said to be venue-sensitive if, for one of the venues, the participant can attend ss, but for the other venue, the participant cannot attend ss.

A venue-sensitive set is problematic for a participant who is interested in attending the lectures in ss because the participant cannot be sure whether the lecture times will overlap. Hyunuk will be happy if and only if there are no venue-sensitive sets. Determine whether Hyunuk will be happy.

입력

The first line contains an integer nn (1n100,0001 \le n \le 100\\,000), the number of lectures held in the conference.

Each of the next nn lines contains four integers sa_isa\_i, ea_iea\_i, sb_isb\_i, eb_ieb\_i (1sa_i,ea_i,sb_i,eb_i1091 \le sa\_i, ea\_i, sb\_i, eb\_i \le 10^9, sa_iea_i,sb_ieb_isa\_i \le ea\_i, sb\_i \le eb\_i).

출력

Print "YES" if Hyunuk will be happy. Print "NO" otherwise.

힌트

In second example, lecture set 1,3\\{1, 3\\} is venue-sensitive. Because participant can't attend this lectures in venue aa, but can attend in venue bb.

In first and third example, venue-sensitive set does not exist.