Curling

아직 제출이 없습니다시간 제한20초메모리 제한1024 MB

문제

2022 is a year of the Winter Olympics! Curling has been one of the most popular winter sports as it requires skill, strategy, and sometimes a bit of luck.

In a curling game, two teams compete by sliding heavy granite stones on a long ice sheet. We call the teams the red team and the yellow team, as their stones are usually distinguished by the red and the yellow handle color. A curling game consists of several ends (subgames); in every end, the teams, each owning 88 stones, take turns to slide them across the long ice sheet toward a circular target area called the house. A stone may hit existing stones to change its own moving direction and other stones' position (including knocking them out of play). Roughly speaking, the goal for a team is to make their stones as close to the center of the house as possible.

Geometrically, a house and a stone can be modeled as a circle and a disk (the region bounded by a circle), respectively, and the scoring rules at the conclusion of each end are formally summarized as follows.

  • Each stone can be viewed as a disk of radius R_s\mathbf{R\_s} on a 22-dimensional plane.
  • The house is a circle of radius R_h\mathbf{R\_h} centered at (0,0)(0, 0).
  • Only stones in the house are considered in the scoring. A stone is in the house if any portion of the stone lies on or within the circle representing the house. Tangency also counts.
  • A team is awarded 11 point for each of their own stones in the house such that no opponent's stone is closer (in Euclidean distance) to the center than it. We assume in this problem that no two stones are equally close to the center (0,0)(0,0).

Two teams are playing and have just delivered all their stones. The red team has N\mathbf{N} stones remaining on the curling sheet, centered at (X_1,Y_1),(X_2,Y_2),,(X_N,Y_N)(\mathbf{X\_1}, \mathbf{Y\_1}), (\mathbf{X\_2}, \mathbf{Y\_2}), \dots, (\mathbf{X\_N}, \mathbf{Y\_N}), while the yellow team has M\mathbf{M} stones remaining, centered at (Z_1,W_1),(Z_2,W_2),,(Z_M,W_M)(\mathbf{Z\_1}, \mathbf{W\_1}), (\mathbf{Z\_2}, \mathbf{W\_2}), \dots, (\mathbf{Z\_M}, \mathbf{W\_M}). Now you are asked to figure out the scores of both teams.

입력

The first line of the input gives the number of test cases, T\mathbf{T}. T\mathbf{T} test cases follow.

Each test case begins with a line containing the two space-separated integers R_s\mathbf{R\_s} and R_h\mathbf{R\_h}.

The next line contains the integer N\mathbf{N}. Then N\mathbf{N} lines follow, the ii-th line of which containing the two space-separated integers X_i\mathbf{X\_i} and Y_i\mathbf{Y\_i}.

After that, similarly, the next line contains the integer M\mathbf{M}. In the next M\mathbf{M} lines, the ii-th line contains the two space-separated integers Z_i\mathbf{Z\_i} and W_i\mathbf{W\_i}.

출력

For each test case, output one line containing Case #x: y z, where xx is the test case number (starting from 1), yy is the score of the red team, and zz is the score of the yellow team.

제한

  • 1T1001 \le \mathbf{T} \le 100.
  • 1R_s<R_h1041 \le \mathbf{R\_s} \lt \mathbf{R\_h} \le 10^4.
  • 0N80 \le \mathbf{N} \le 8.
  • 2×104X_i2×104-2 \times 10^4 \le \mathbf{X\_i} \le 2 \times 10^4, for all ii.
  • 2×104Y_i2×104-2 \times 10^4 \le \mathbf{Y\_i} \le 2 \times 10^4, for all ii.
  • 2×104Z_i2×104-2 \times 10^4 \le \mathbf{Z\_i} \le 2 \times 10^4, for all ii.
  • 2×104W_i2×104-2 \times 10^4 \le \mathbf{W\_i} \le 2 \times 10^4, for all ii.
  • The distances between the center of each stone and the center of the house (0,0)(0, 0) are distinct, i.e., no two stones are equally close to the center of the house.
  • No two stones overlap (but two stones can be tangent).