Dolphins

Simulate fish that swim one unit away from a dolphin each step, and count how many trajectories hit the net polygon.

Medium6GeometrySimulationImplementationBrute forceNo attempts yetTime limit2sMemory limit512 MB

Problem

Dolphins are good at herding a school of fish so that the whole school swims in one direction. Some aboriginal tribes in Australia used that habit to fish together with wild dolphins. The dolphins drove a school toward the nets, the fishermen caught a large number of fish at once, and the fishermen shared the catch with the dolphins. Driving a whole school is much easier for a dolphin than catching fish one by one.

You are given the path of one dolphin, the starting positions of the fish, and the position of the net. Count how many fish the fishermen catch.

The simulation runs over tt time steps in the plane. The position of the dolphin is given for every time step from 11 to t1t-1. At each of those steps every fish checks where the dolphin is and swims exactly distance 11 in a straight line, in the direction pointing from the dolphin to itself. The distance between a fish and the dolphin is always greater than 0.10.1.

The net is a polygon through nn corners given in order, and the last corner joins back to the first, so the boundary is closed. The net never touches or overlaps itself. A fish is caught as soon as the segment it travels during one swim meets the boundary of the net in at least one point. Meeting at an endpoint of that segment, or at a corner of the net, counts as caught. A caught fish ends its simulation there and does not move again. No fish starts on the boundary of the net.

Input

The first line contains the number of data sets KK (1K101 \le K \le 10). Then KK data sets follow, each in the form below.

The first line of a data set contains three integers nn, ff, tt. nn (3n1003 \le n \le 100) is the number of corners of the net, ff (0f1000 \le f \le 100) is the number of fish, and tt (1t1001 \le t \le 100) is the number of time steps of the simulation.

The next line contains 2n2n real numbers a1a_1, b1b_1, a2a_2, b2b_2, ..., ana_n, bnb_n, the coordinates of the corners of the net in order.

The next line contains 2(t1)2(t-1) real numbers p1p_1, q1q_1, ..., pt1p_{t-1}, qt1q_{t-1}, the positions of the dolphin at time steps 11 through t1t-1. This line is empty when t=1t = 1. The position of the dolphin at the last time step is not given because it does not affect the result.

Each of the next ff lines contains two real numbers xix_i, yiy_i, the position of fish ii at time step 11.

All coordinates are between 1000-1000 and 10001000.

Output

For each data set, first print Data Set x: on a line of its own, where xx is the number of the data set counting from 11. On the next line print the number of fish caught. Print one blank line after each data set.