Decide whether two polygonal paths from s to t in a plane with point obstacles are homotopic, that is, deformable into each other without crossing any tree.
Hard8GeometryImplementationHash mapSortingNo attempts yetTime limit2sMemory limit512 MBSoroush walks a path he fixed in advance through the bird garden, from the entrance to the exit, watching the birds in the trees. His dog on a leash does not have to follow the same path, but it reaches the exit in the end. The garden holds tall trees and no other obstacle. The leash takes any length from 0 upward, and at every moment it pulls to the shortest length it can take. Soroush and his dog start at the entrance with the leash length 0. Soroush knows his dog's path in advance, and he wonders whether the leash length can be 0 at the moment the two of them arrive at the exit. The leash cannot pass over a tree. When the leash length is 0 at the exit, Soroush's path and his dog's path are called homotopic.
Each path is the sequence of segments joining the given points in order. A tree is a single point of the plane, and neither path passes through a tree. Two paths are homotopic when one can be deformed continuously into the other while both endpoints stay fixed and no intermediate position crosses a tree. Write a program that decides whether two given paths are homotopic.
The input holds several test cases. The first line of each test case contains the integers n, m and k (1≤n≤1000, 0≤m,k≤1000). Here n is the number of trees, and m and k are the numbers of intermediate vertices of Soroush's path and of his dog's path. The next two lines contain the x and y coordinates of the entrance s and of the exit t, in that order (s=t). The next n lines contain the x and y coordinates of the trees. Let Soroush's path be s,v1,…,vm,t and his dog's path be s,u1,…,uk,t. The following m lines then contain the coordinates of v1 through vm in order, and the k lines after them contain the coordinates of u1 through uk in order.
A path may intersect itself, and the two paths may intersect each other. No tree lies on either path, including at s and t. Every coordinate is an integer whose absolute value is at most 106. The input ends with a line containing 0 0 0, which you do not process.
For each test case, print Yes on its own line if the two paths are homotopic, and No otherwise.