spoj#FSHEEP. Fencing in the Sheep
Fencing in the Sheep
A shepherd is having some trouble penning in his flock of sheep. After several hours of ineffectual efforts he gives up, with some of the sheep within their polygon-shaped pen and some outside. Exhausted, he moves to a place within the pen from which he can see the whole interior of the pen (without any fence getting in the way) and begins to count the sheep which are within it. Please assist him in his task.
Input
The input begins with the integer t, the number of test cases. Then t test cases follow.
The first line of each test case contains two integers n m, denoting the number of vertices of the polygon forming the fence, and the number of sheep in the whole herd (3<=n<=100000, 0<=m<=100000). The next n lines contain two integers each, the i-th being xi yi - the x and y coordinates of the i-th vertex of the fence (given in anti-clockwise order, -32000<=xi,yi<=32000). The next m lines contain two integers each, the j-th being xj yj - the x and y coordinates of the j-th sheep (arranged in decreasing order of seniority, -32000<=xj,yj<=32000). The shepherd's observation point is within the pen and has coordinates (0,0).
Output
For each test case output a line with a single integer - the number of sheep within the pen. The sheep which are sitting back on the fence and enjoying a cigarette should be included in the count.
Example
Sample input: 1 6 5 2 2 4 4 6 6 -3 1 -1 -1 5 1 2 1 3 2 6 6 3 3 -3 0</p>Sample output: 3
Illustration of the sample test data: