Олимпиадный тренинг

Задача 38382. History of one country


Задача

Темы:
For the summer holidays, Petya came to Bytland. As it turned out, the history of this state is very unusual.

Initially, before the appearance of Byteland, n different countries were located on its territory. Each state owned its own territory, which could be represented on the map as a rectangle, the sides of which are parallel to the coordinate axes, and the vertices are located at integer points. No two countries overlapped, but they could touch each other. Sometimes, as a result of aggressive negotiations and peaceful military campaigns, two countries united into one. The merger occurred only if, after the unification of their possessions, a rectangular territory was again obtained. In the end, only one state remained — Byteland.

At the beginning of time, the territory of each country contained within itself exactly one rectangular castle, where the sides of this castle are parallel to the coordinate axes, and the vertices are located at integer points. It is assumed that the borders of the castle could be adjacent to the border of the corresponding territory of the country and to the borders of other castles. Surprisingly, even after all the coups, the castles are perfectly preserved. But, unfortunately, this is the only information that allows us to somehow judge the original location of the countries.
 
Possible Byteland formation. Locks are marked in blue.
 
Petya could not come to terms with the fact that there was no data left about the original countries. He had a suspicion that the whole story was just fiction. He knows that you are a smart person, and therefore he asks you for help. It is required to find out whether there is a location of the original states for which this story can be true or not.

Input
The first line contains a single integer n (1 ≤ n ≤ 100000) — number of castles and countries.

Each of the next n lines contains four integers ai, bi, ci, di (0 ≤ai <ci ≤109, 0 ≤bi  <di ≤109) — coordinates of the vertices of the i-th lock, where (ai, bi) — coordinates of the lower left point, and (ci, di) — top right.

It's guaranteed that no two locks intersect, but they can touch each other.

Imprint
If there are locations of original countries for which this story is true, then print « YES ", otherwise print " NO».

Note
The pictures below show the location of the locks in the first and second examples.
Examples
# Input Output
1 4
0 0 1 2
0 2 1 3
1 0 2 1
1 1 2 3
YES
2 4
0 0 2 1
1 2 3 3
2 0 3 2
0 1 1 3
NO