시간 제한메모리 제한제출정답맞힌 사람정답 비율
서브태스크 참고 (추가 시간 없음) 1024 MB0000.000%

## 문제

The first international Geese conference just wrapped up, and even though it should have been a happy occasion, it was bittersweet. The organizers found a paper with detailed plans of a duck infiltration. Now, they are trying to identify the infiltrating group from among the attendees.

The document that they found contained a list of $\mathbf{M}$ triples of integers $(\mathbf{X_i}, \mathbf{Y_i}, \mathbf{C_i})$ meaning the ducks would meet exactly $\mathbf{C_i}$ seconds after the start of the conference at point $(\mathbf{X_i}, \mathbf{Y_i})$, which is $\mathbf{X_i}$ meters east and $\mathbf{Y_i}$ meters north of the center of the conference floor. Each goose may or may not have been at those specific points at those specific times, but every duck certainly was.

Both ducks and geese walk at a maximum speed of one meter per second, which means an attendee that is at point $(x, y)$ at time $t$ can reach any point of the form $(x + \Delta_{x}, y + \Delta_{y})$ by time $t + \Delta_{t}$ as long as ${\Delta_{x}}^2 + {\Delta_{y}}^2 \le {\Delta_{t}}^2$. Each attendee's position at time $0$ can be any point, independently of the other attendees. After the discovery, the group held a questioning session to try to identify the ducks. During that session, attendees issued a series of statements, one at a time. The $j$-th of those, in the order they were issued, was made by attendee $\mathbf{A_j}$, claiming that both they and attendee $\mathbf{B_j}$ were at point $(\mathbf{U_j}, \mathbf{V_j})$ exactly $\mathbf{D_j}$ seconds after the start of the conference. Points in statements may or may not be points where duck meetings happened.

Statements from geese are always true, but ducks may lie. Moreover, ducks know which attendees are ducks and which are geese. To avoid getting caught easily, ducks only make statements that are consistent with all statements previously made by geese. Note that statements made by geese are consistent with all ducks being at all duck meetings.

It may not be possible to determine all the ducks with the information provided. However, knowing the minimum number of ducks will at least provide a lower bound on the level of duck activity. Note that there was at least one duck. Find this minimum number of ducks.

Formally, a hypothesis $H$ is a partition of all attendees into a set of ducks (named $H$-ducks) and geese (named $H$-geese). $H$ is consistent with a set of statements $S$ if there exists a path for each attendee moving at most one meter per second such that:

• all $H$-ducks were at all duck meetings and
• for each statement in $S$ claiming that $A$ saw $B$ at point $P$ at time $T$, both $A$ and $B$⁠'s paths went through point $P$ at time $T$.

A hypothesis $H$ is feasible under a set of statements $S$ if:

• $H$-ducks is not empty (i.e., there was at least one duck),
• the subset of all statements from $S$ made by members of $H$-geese is consistent with $H$ (i.e., statements from geese are always true), and
• for each statement $s \in S$ made by a member of $H$-ducks, if $P \subseteq S$ is the subset of statements made by members of $H$-geese issued before $s$, there exists a hypothesis $H'$ (which may or may not be equal to $H$) such that $\{ s \} \cup P$ is consistent with $H'$ (i.e., ducks do not contradict previous statements made by geese).

Notice that the hypotheses $H$ such that $H$-ducks contains all attendees is always feasible.

Find the minimum size of $H$-ducks over all feasible hypotheses $H$.

## 입력

The first line of the input gives the number of test cases, $\mathbf{T}$. $\mathbf{T}$ test cases follow. Each test case starts with a line containing three integers, $\mathbf{N}$, $\mathbf{M}$, and $\mathbf{S}$, representing the numbers of attendees, duck meetings, and statements, respectively. The next $\mathbf{M}$ lines each describe a different duck meeting with three integers $\mathbf{X_i}$, $\mathbf{Y_i}$, and $\mathbf{C_i}$, representing that there was a meeting at point $(\mathbf{X_i}, \mathbf{Y_i})$, held exactly $\mathbf{C_i}$ seconds after the start of the conference. Then, the last $\mathbf{S}$ lines of a test case each describe a statement. The $j$-th of these lines describes the $j$-th issued statement with five integers $\mathbf{A_j}$, $\mathbf{B_j}$, $\mathbf{U_j}$, $\mathbf{V_j}$, and $\mathbf{D_j}$, representing that attendee $\mathbf{A_j}$ stated that they and attendee $\mathbf{B_j}$ were both at point $(\mathbf{U_j}, \mathbf{V_j})$ exactly $\mathbf{D_j}$ seconds after the start of the conference.

## 출력

For each test case, output one line containing Case #x: y, where $x$ is the test case number (starting from 1) and $y$ is the minimum number of ducks that might have infiltrated the conference.

## 제한

• $1 \le \mathbf{T} \le 50$.
• $-10^9 \le \mathbf{X_i} \le 10^9$, for all $i$.
• $-10^9 \le \mathbf{Y_i} \le 10^9$, for all $i$.
• $1 \le \mathbf{C_i} \le 10^9$, for all $i$.
• $\mathbf{C_i} \lt \mathbf{C_{i+1}}$, for all $i$.
• $(\mathbf{X_i} - \mathbf{X_{i+1}})^2 + (\mathbf{Y_i} - \mathbf{Y_{i+1}})^2 \le (\mathbf{C_i} - \mathbf{C_{i+1}})^2$, for all $i$.
• $1 \le \mathbf{A_j} \le \mathbf{N}$, for all $j$.
• $1 \le \mathbf{B_j} \le \mathbf{N}$, for all $j$.
• $\mathbf{A_j} \ne \mathbf{B_j}$, for all $j$.
• $-10^9 \le \mathbf{U_j} \le 10^9$, for all $j$.
• $-10^9 \le \mathbf{V_j} \le 10^9$, for all $j$.
• $1 \le \mathbf{D_j} \le 10^9$, for all $j$.
• $(\mathbf{A_j}, \mathbf{B_j}, \mathbf{U_j}, \mathbf{V_j}, \mathbf{D_j}) \ne (\mathbf{A_k}, \mathbf{B_k}, \mathbf{U_k}, \mathbf{V_k}, \mathbf{D_k})$, for all $j \ne k$.

## Test Set 1 (11점)

시간 제한: 20 초

• $2 \le \mathbf{N} \le 50$.
• $1 \le \mathbf{M} \le 50$.
• $1 \le \mathbf{S} \le 50$.

## Test Set 2 (24점)

시간 제한: 60 초

• $2 \le \mathbf{N} \le 10^5$.
• $1 \le \mathbf{M} \le 10^5$.
• $1 \le \mathbf{S} \le 10^5$.

## 예제 입력 1

2
2 1 2
1 2 3
1 2 1 1 1
2 1 2 2 2
4 2 4
4 3 10
-4 -3 20
1 3 4 3 11
2 4 0 0 16
3 1 6 3 9
4 2 0 0 16


## 예제 출력 1

Case #1: 1
Case #2: 2


## 힌트

In Sample Case #1, attendee 1 being the only duck is a feasible hypothesis.

In Sample Case #2, attendees 2 and 4 being the only ducks is a feasible hypothesis. Note that there is at least one duck, so all attendees being geese is not feasible.

## 채점 및 기타 정보

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