ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules

2202. Gorodki and Robots

Time limit: 3.0 second
Memory limit: 256 MB
Gorodki is a Russian sports game. In it, players must use a precise throw of a bat, pole, or another stick to destroy so-called “gorodki” — structures made of small wooden blocks.
Problem illustration
But time does not stand still, and now the destruction of structures is carried out not by humans, but by robots. The rules of the game are very simple. On a huge field, there are 2 · N gorodki with integer coordinates, grouped into pairs (that is, a total of N pairs of gorodki), among which there are no two gorodki with the same coordinates. There are N robots — machines that run on oil. At the beginning of the game, a robot is deployed on any undestroyed gorodki and immediately destroys it, while the robot itself remains intact. Then this robot must travel to the corresponding second gorodki of the pair. The route can be any, including a straight line, a polygonal chain, or a curve. Upon reaching the second gorodki of the pair, the robot quietly self-destructs, destroying this and only this gorodki. After the robot’s destruction, a new robot is deployed, destroying one of the gorodki upon landing, then it travels to the second gorodki of the pair and self-destructs, destroying that gorodki. This continues until all N robots have self-destructed and all 2 · N gorodki have been destroyed. The robot’s path must not pass through any gorodki except for the two it is supposed to destroy.
Each robot has a design flaw: while moving, it constantly leaks oil. As the robot moves, it leaves an oil trail in the form of a continuous curve that exactly follows its route. If a robot hits the oil trail, it immediately breaks down, making it impossible to successfully complete the game; therefore, the paths of the robots must not intersect.
To make the game more exciting, an oil trail has been drawn on the field in the form of a rectangle with the coordinates of the vertices (0; 0), (W; 0), (W; H), (0; H). Gorodki can be located both outside the rectangle and inside it, as well as on the border of the rectangle. A robot never breaks down when landing on a gorodki, even if it was right on the border of the rectangle, but the robot will break down if it runs over the drawn trail. A gorodki is always destroyed when the robot reaches it, even if that gorodki was on the border of the rectangle.
It is assumed that the sizes of the robots and gorodki and the thickness of the oil trails are so small that robots and gorodki can be considered points, and trails — curves.
The game is considered failed if one of the robots breaks down without destroying the second gorodki of the pair it was supposed to reach. If all N pairs of gorodki are destroyed by N robots, then the game is considered won.
The task is to determine whether it is possible to arrange the robots’ routes in such a way as to destroy all gorodki.

Input

The first line contains three integers separated by spaces: N, W, and H — the number of pairs of gorodki, the width of the rectangle, and the height of the rectangle, respectively (1 ≤ N ≤ 105, 1 ≤ W, H ≤ 108).
Each of the following N lines contains 4 integers x1, y1, x2, y2, where (x1; y1) — are the coordinates of the first gorodki of the pair, and (x2; y2) — are the coordinates of the second gorodki of the same pair (−108x1, y1, x2, y2 ≤ 108).
It is guaranteed that the coordinates of all gorodki are pairwise distinct; this applies to both gorodki from the same pair and gorodki from different pairs.

Output

The output should be a single line containing “YES” (without quotes) if it is possible to destroy all gorodki using N robots, and “NO” (without quotes) otherwise.

Samples

inputoutput
1 2 2
-1 1 3 1
YES
3 4 4
0 0 3 3
4 0 1 3
2 4 2 0
YES
3 4 4
0 0 4 4
4 0 0 4
2 4 2 0
NO
Problem Author: Valentin Zuev
Problem Source: University academic school olympiad in informatics 2020