Cowboy Beblop is a funny little boy who likes sitting at his computer. He somehow obtained two elastic hoops in the shape of
For both hoops, you are given the number of their vertices, as well as the position of each vertex, defined by its
Cowboy Beblop is fascinated with the hoops he has obtained and he would like to know whether they are connected or not. Since he's busy playing with his dog, Zwei, he'd like you to figure it out for him. He promised you some sweets if you help him!
Input Specification
The first line of input contains an integer
The next
The next line contains an integer
Output Specification
Your output should contain only one line, with the words YES
or NO
, depending on whether the two given polygons are connected.
Constraints
- It is guaranteed that both polygons are simple (no self-intersections), and in general that the obtained polygonal lines do not intersect each other. Also, you can assume that no
consecutive points lie on the same line.
Sample Input
4
0 0 0
2 0 0
2 2 0
0 2 0
4
1 1 -1
1 1 1
1 3 1
1 3 -1
Sample Output
YES
Explanation
In the picture below, the two polygons are connected, as there is no way to pull them apart (they are shaped exactly like two square links in a chain). Note that the polygons do not have to be parallel to any of the
Comments
In case the question is not clear, all vertices in a polygon are coplanar.