404344: GYM101484 E Double Fence

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

E. Double Fencetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

Danfsk bought some sheep and wants to protect them from wolves. He had the brilliant idea of building two convex fences, one strictly inside the other, and keeping all sheep inside the inner fence. This way, the sheep would have a second layer of protection from the wolves.

He hired Tomask, a famous fence architect, to design two fences for him. After finishing his project, Tomask gave Danfsk two pieces of paper, each containing the coordinates of the poles of a convex fence.

Tomask is also famous for miscalculations on his projects, so, before paying Tomask and starting building the fences, Danfsk wants to check if one convex fence is really strictly inside the other in Tomask's project. He asked you to help him with this task.

Input

The first line of the input contains two integers N and M (3 ≤ N, M ≤ 105) indicating respectively the number of poles of the first convex fence and the number of poles of the second convex fence.

Each of the following N lines contains two integers: the i-th line contains xi1 and yi1 ( - 109 ≤ xi1, yi1 ≤ 109), indicating the coordinates of the i-th pole of the first fence.

Each of the following M lines contains two integers: the i-th line contains xi2 and yi2 ( - 109 ≤ xi2, yi2 ≤ 109), indicating the coordinates of the i-th pole of the second fence.

Each fence has the shape of a convex polygon. Pole coordinates of each fence are given in clockwise order. No two points in the project are the same.

Note that there may be colinear poles in the project.

Output

Output YES if one fence is strictly inside the other (the first fence is strictly inside the second or vice versa). Output NO otherwise.

ExamplesInput
4 4
1 1
1 -1
-1 -1
-1 1
2 2
2 -2
-2 -2
-2 2
Output
YES
Input
4 3
0 0
0 3
3 3
3 0
1 1
2 3
2 1
Output
NO
Input
3 3
2 1
5 1
2 -1
-3 1
0 1
0 -1
Output
NO

Source/Category

加入题单

上一题 下一题 算法标签: