9160 - PNPOLY   

Description

Given a 2D point, answer if the point is inside a simple 2D polygon of N vertices?
Note that points lie on the vertices or edges of polygon are not considered inside.

Input

The first line is an integer t which indicates the number of test cases.

For each case, the first line is an integer N that denotes the number of vertices of a polygon followed by a list of n pairs of vertices' 2D coordinates (x, y) in counter-clockwise order. All vertices on the polygon are in the rectangle [-20000, 20000]x[-20000,20000].


The next line is an integer q(1 <= q <= 100) indicates the number of test point followed by a list of q pairs of points' 2D coordinates. The bound of x and y coordinate of query points is between -106 and 106.

Size of each data:

Data set 1: N <= 100

Data set 2: N <= 100

Data set 3: N <= 10000

Data set 4: N <= 10000

Output

The output is a line with 'Yes' if the test point is inside the polygon, otherwise output a line with 'No'(without quote).

Sample Input  Download

Sample Output  Download

Tags




Discuss