시간 제한메모리 제한제출정답맞힌 사람정답 비율
20 초 (추가 시간 없음) 1024 MB19141473.684%

문제

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 $8$ 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 $\mathbf{R_s}$ on a $2$-dimensional plane.
  • The house is a circle of radius $\mathbf{R_h}$ centered at $(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 $1$ 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)$.

Two teams are playing and have just delivered all their stones. The red team has $\mathbf{N}$ stones remaining on the curling sheet, centered at $(\mathbf{X_1}, \mathbf{Y_1}), (\mathbf{X_2}, \mathbf{Y_2}), \dots, (\mathbf{X_N}, \mathbf{Y_N})$, while the yellow team has $\mathbf{M}$ stones remaining, centered at $(\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, $\mathbf{T}$. $\mathbf{T}$ test cases follow.

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

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

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

출력

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

제한

  • $1 \le \mathbf{T} \le 100$.
  • $1 \le \mathbf{R_s} \lt \mathbf{R_h} \le 10^4$.
  • $0 \le \mathbf{N} \le 8$.
  • $-2 \times 10^4 \le \mathbf{X_i} \le 2 \times 10^4$, for all $i$.
  • $-2 \times 10^4 \le \mathbf{Y_i} \le 2 \times 10^4$, for all $i$.
  • $-2 \times 10^4 \le \mathbf{Z_i} \le 2 \times 10^4$, for all $i$.
  • $-2 \times 10^4 \le \mathbf{W_i} \le 2 \times 10^4$, for all $i$.
  • The distances between the center of each stone and the center of the house $(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).

Test Set 1 (7점)

  • $\mathbf{M} = 0$.

Test Set 2 (10점)

  • $0 \le \mathbf{M} \le 8$.

예제 입력 1

2
1 5
4
1 -1
6 1
0 6
-5 0
0
10 100
2
-3 -4
200 200
0

예제 출력 1

Case #1: 3 0
Case #2: 1 0

The following picture illustrates Sample Case #1. The big circle with a light blue interior represents the house, and the red disks represent the red team's stones.

In this case, the yellow team has no stones left in the house, so the red team receives a point for each of their stone in the house. All the existing stones are in the house except the one centered at $(6, 1)$ (it would have touched the house boundary if it were centered at $(6, 0)$), so the red team gets $3$ points.

예제 입력 2

2
1 5
2
1 0
-3 0
1
0 2
10 50
2
-40 -31
-35 70
3
59 0
-10 0
30 40

예제 출력 2

Case #1: 1 0
Case #2: 0 2

The following picture illustrates Sample Case #1. Besides the big circle and the red disks, the yellow disk represents the yellow team's only remaining stone.

In this case, both teams have stones inside the house. The red stone at $(1, 0)$ is in the house and no yellow stone is closer than it to the center of the house, so it is worthy of a point. Although the other red stone (centered at $(-3, 0)$) is also in the house, it is not worthy of a point because the yellow stone centered at $(0, 2)$ is closer than it to the center $(0,0)$. The yellow stone is not worthy of a point, either, due to the existence of the red stone at $(1, 0)$. Therefore, the red team gets $1$ point and the yellow team gets $0$ points.

채점 및 기타 정보

  • 예제는 채점하지 않는다.