cho.sh
Notes
Loading...

Robot Arm

Time limit

5s

Memory limit

128 MB

Problem

A factory robot is fixed at a point F. It has one joint A, two straight arms B and C, and a hand D. Arm B connects F to A, and arm C connects A to D.

Arm B may extend horizontally left or right from F, or vertically up or down from F. Arm C must always extend perpendicular to arm B from A. Both arms may have any nonnegative length.

The factory floor is a simple polygon whose boundary alternates between horizontal and vertical wall segments, so there are no walls inside the polygon.

For a given position of F, some interior points of the factory may be impossible for the hand D to reach, no matter how the two arm lengths and the joint position are chosen.

Given the polygon boundary and five possible fixed-axis positions, determine for each position whether the robot hand can reach every point in the factory interior. The fixed axis is always inside the factory. The factory interior does not include the boundary, but the arms are allowed to move along the boundary. The fixed axis, joint, and hand are points, and the arms are line segments with no thickness.

Input

The first line contains the number of polygon vertices N, where 4 <= N <= 20000.

Each of the next N lines contains two integers X and Y, the coordinates of one polygon vertex. The vertices are given in counterclockwise order along the boundary. Every coordinate is an integer between 0 and 1000000, inclusive.

The next five lines each contain two integers X and Y, the coordinates of one possible fixed-axis position.

Output

For each of the five fixed-axis positions, in input order, print one line. Print YES if the robot hand can reach every point in the factory interior from that fixed-axis position, and NO otherwise.

Hint

The figure illustrates a factory shape and several fixed-axis positions.