eolymp
bolt
Try our new interface for solving problems
Problems

Point in polygon

Point in polygon

As is known, a simple polygon is a figure consisting of disjoint segments ("sides") connected in pairs with the formation of a closed path. Given a simple polygon and a point, determine whether this point lies inside or on the boundary of this polygon or outside it.

Input

The first line contains three integers: n (3n105) and point coordinates. Next n lines contains pair of numbers - the coordinates of the next vertex of a simple polygon in the order of traversing by or counter-clockwise.

Output

Print the string "YES" if the given point is inside the given polygon or on its border, and "NO" otherwise.

Time limit 1 second
Memory limit 128 MiB
Input example #1
3 0 0
1 0
0 1
1 1
Output example #1
NO
Input example #2
4 3 2
0 0
1 5
5 5
6 0
Output example #2
YES
Source 2018 Azerbaijan School Competition, II Stage, April 8, Problem J