Hole in One

Decide whether a ball can reach the hole with at most one bounce off any of N line-segment obstacles or the four walls.

Medium7GeometryBrute forceImplementationNo attempts yetTime limit5sMemory limit512 MB

Problem

Mini golf asks you to hit a ball from its starting position into a hole, possibly bouncing off objects on the way.

You want more practice, so you are writing a computer program that helps you. The program decides whether one shot can put the ball in the hole. You are still an amateur, so you only take a shot that bounces off at most one object before the ball lands in the hole.

The course is a rectangle with NN obstacles on it, and every obstacle is a straight line segment inside the course. The obstacles are infinitely thin, and the ball and the hole are points.

Given a description of the course, the location of the hole and the starting location of the ball, decide whether one shot with at most one bounce can put the ball in the hole. The ball can bounce off any of the NN obstacles or any of the 4 walls. The ball may not touch the endpoint of any obstacle. If the ball touches a point where two objects meet, whether those objects are obstacles or walls, that counts as hitting two objects.

Input

The first line contains three integers NN (0N10000 \le N \le 1000), which is the number of obstacles on the course, WW (3W1003 \le W \le 100), which is the width of the course, and HH (3H1003 \le H \le 100), which is the height of the course.

The second line contains two integers xx (1x<W1 \le x < W) and yy (1y<H1 \le y < H), the coordinates of the ball.

The third line contains two integers xx (1x<W1 \le x < W) and yy (1y<H1 \le y < H), the coordinates of the hole.

Each of the next NN lines describes one obstacle with four integers x1x_1 (0x1W0 \le x_1 \le W), y1y_1 (0y1H0 \le y_1 \le H), x2x_2 (0x2W0 \le x_2 \le W) and y2y_2 (0y2H0 \le y_2 \le H), which means there is an obstacle that is a straight line segment with endpoints (x1,y1)(x_1, y_1) and (x2,y2)(x_2, y_2). It is guaranteed that (x1,y1)(x2,y2)(x_1, y_1) \ne (x_2, y_2).

The ball and the hole are at distinct locations, and neither of them touches any object, wall or obstacle. Objects may intersect each other, but two objects never overlap in more than one point.

Output

Print YES if one shot with at most one bounce can put the ball in the hole. Otherwise print NO.