8624: Bowling

内存限制:128 MB 时间限制:5 S
题面:传统 评测方式:文本比较 上传者:
提交:1 通过:1

题目描述

Little Rabbit has recently become interested in a special kind of bowling. The bowling ball can be seen as a convex polygon on a two-dimensional plane. And the pins (the target of the bowling ball) can be seen as points on the plane.

As with regular bowling, the goal is to make the bowling ball hit as many pins as possible. We can suppose that the bowling ball makes a translational motion on the plane. Once the pin touches the bowling ball (including the boundary), the pin will be knocked down and will not affect the direction of the bowling ball's motion.

Now given the position of the bowling ball and the pins, for different directions of the bowling ball's motion, please calculate how many pins it can knock down.

输入格式

The first line of the input contains an integer T 1T100), indicating the number of test cases.

For each test case, the first line contains an integer n 3n105), indicating the number of vertices of the convex polygon.

Each of the next n lines contains two integers x,y x,y109), indicating that the coordinates of a vertex of the convex polygon are (x,y). The vertices are given in counterclockwise order, and there are no three vertices collinear.

The next line contains an integer 1m105), indicating the number of pins.

Each of the next mm lines contains two integers x,y x,y109), indicating that the coordinates of a pin are (x,y). It is guaranteed that the pins are located strictly at the outside of the polygon.

The next line contains an integer q 1q105), indicating the number of queries.

Each of the next q lines contains two integers x,y x,y109), indicating that the direction vector of the bowling ball's motion is (x,y). It's guaranteed that (x,y)!=(0,0).

It is guaranteed that nnm, andq over all test cases do not exceed 2×105.

输出格式

For each query, output an integer in a single line indicating the number of pins the bowling ball can knock down.

输入样例 复制

1
4
0 0
2 0
2 2
0 2
5
1 4
3 1
4 2
5 1
3 3
3
0 1
1 0
1 1

输出样例 复制

1
3
3