Question: Only certain humans understand that the Alex is likewise a present day artist. In his spare time, he makes artwork which do not stink of

Only certain humans understand that the Alex is likewise a present day artist. In his spare time, he makes artwork which do not stink of traditions. They are like whiffs of clean air, full of experimentation. So, now you recognize all those err.. stunning portions of artwork in Alexs restaurant, are his personal works!

Here is how he makes a chunk of present day artwork - First he is taking a big thin timber board. Then he attracts a large polygon on it, using crayons. Then in numerous wild swings, he attracts numerous lines at the board. You might imagine it's far simple, however it isn't always so. After so many years of enjoy in cutting potatoes and tomatoes he has become very correct in marking points at the board. So what's extraordinary is, that each corner of the polygon, and each beginning and finishing factor of the line is an integral factor, i.e may be represented as in which x and y each are integers. Another point really well worth pointing out is that Alex believes in symmetry. This is seen from following fact- "If we divide complete wooden board into sixteen rectangular shaped (virtual) regions, the distinction in range of lines contained withinside the location with most lines and the location with minimal lines does not exceed 50%". A location is stated to include a line if as a minimum one end factor of line is inside it.

It would not end here. Then Alex takes colorful (sewing) needles and nails them on each point on the road traced through crayon, such that the point is vital and it lies both on or inside the polygon. As polygon obstacles also are lines, needles are pinned on them as well. Finally he is taking board pins with colorful heads and pins them withinside the polygon such that the point isn't always already occupied through needle and the factor is vital. Lo and behold! The portray is ready!

The needles and board pins are as an alternative costly, so Alex neither desires to shop for the needles and pins in excess, nor does he need to run quick of them. Now, he desires your assist to inform him the precise range of needles and pins that he might require. We can pay attention the Alex singing ..and nonetheless it begins, needles and pins ... slowly. Input First line contains an integer T, the number of test cases. For each test case - first line contains two integers N, number of vertices of polygon and M, number of lines. Then N lines follow, each containing 2 space separated integers X Y denoting the ith vertex. The vertices are given anti-clockwise. Next M lines contains 4 space separated integers X1 Y1 X2 Y2 denoting 2 end points of the jth line. No line is longer than 10000 units in length.

Output For each test case - output on a single line the number of needles required and the number of pins required Sample Input 1 4 4 0 0 6 0 4 2 2 2 1 0 4 0 2 4 2 -1 0 0 -1 -1 0 1 3 1

Output 14 1

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!