

The first line of input contains an integer ‘T’, the number of test cases.
The first line of each test case contains a single integer ‘N’, representing the number vertices of the fence.
The next ‘N’ lines will denote the coordinates of the fence in the X-Y place.
The ‘N + 1’th line will denote the coordinates of the animal in the X-Y plane.
For each test case, return a single integer ‘1’ if the animal is safe, else print ‘0’.
Print output of each test case in a separate line.
You do not need to print anything, it has already been taken care of. Just implement the given function.
1 <= T <= 10
1 <= N <= 2*10^3
-10^4 <= X, Y <= 10^4
Time Limit: 1 sec
The basic idea is to make a horizontal line to the right of each point by extending it. We count the number of times the animal line segment intersects with the fence line segment. If the intersection is an odd number of times then the point lies in the circle, else it lies outside the circle.
Special case: When the coordinates of the animal are colinear with line segments of the fences, we check whether that point lies on the segment or not. If it lies on the segment it is considered to be inside the fence
Here is the algorithm :
INTERSECT(‘F1’, ‘F2, ‘A1’, ‘A2’) (Function to find the intersection of line segments.)
ORIENTATION(‘P’, ‘Q’, ‘R’) (Function to find the orientation.)
onLine(‘P’, ‘Q’, ‘R’) (Function to check whether a point lies on the line or not.)
Construct The Parameter
Construct The Parameter
Construct The Parameter
Construct The Parameter
Construct The Parameter
Construct The Parameter
Construct The Parameter
Construct The Parameter
Construct The Parameter
Construct The Parameter
Construct The Parameter
Construct The Parameter
Construct The Parameter
Points Visible
Points Visible
Points Visible
Circle Intersection
Circle Intersection
Circle Intersection
Circle Intersection
City Lights
Angler's Race