Problems
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
Both ducks and geese walk at a maximum speed of one meter per second,
which means an attendee that is at point
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
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
- all
H -ducks were at all duck meetings and - for each statement in
S claiming thatA sawB at pointP at timeT , bothA andB 's paths went through pointP at timeT .
A hypothesis
H -ducks is not empty (i.e., there was at least one duck),- the subset of all statements from
S made by members ofH -geese is consistent withH (i.e., statements from geese are always true), and - for each statement
s \in S made by a member ofH -ducks, ifP \subseteq S is the subset of statements made by members ofH -geese issued befores , there exists a hypothesisH' (which may or may not be equal toH ) such that\{ s \} \cup P is consistent withH' (i.e., ducks do not contradict previous statements made by geese).
Notice that the hypotheses
Find the minimum size of
Input
The first line of the input gives the number of test cases,
Output
For each test case, output one line containing Case #,
where
Example
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
Case #1: 1
Case #2: 2