Suspects and Witnesses

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

문제

Ada baked some cookies for her birthday party where she invited N\mathbf{N} guests, labeled 11 to N\mathbf{N}. When all the guests have arrived and the party is about to start, something terrible has happened — someone stole the cookies!

Ada puts on her detective hat and starts questioning her guests. She gathered M\mathbf{M} witness statements of the form: Guest x: "Guest y did not steal the cookies."

Ada knows that, if a guest is innocent (did not steal a cookie), then all their witness statements must be true. Note that Ada does not know whether any statement made by a cookie stealer is correct.

Lastly, Ada has an informant who told her there can be at most K\mathbf{K} cookie stealers. With this information, can you help Ada find out the number of guests who can be proved to be innocent?

Note that it is possible that no guest actually stole the cookies, and Ada simply forgot how many cookies she baked.

입력

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

The first line of each test case contains three integers N\mathbf{N}, M\mathbf{M}, and K\mathbf{K}: the number of guests, the number of witness statements, and the maximum number of cookie stealers, respectively.

The next M\mathbf{M} lines describe the witness statements. The ii-th line contains two integers A_i\mathbf{A\_i} and B_i\mathbf{B\_i}, which means the witness statement Guest A_i\mathbf{A\_i}: "Guest B_i\mathbf{B\_i} did not steal the cookies."

출력

For each test case, output one line containing Case #$x$: $y$, where xx is the test case number (starting from 1) and yy is the number of guests that can be proved to be innocent.

제한

  • 1T1001 \le \mathbf{T} \le 100.
  • 2N1052 \le \mathbf{N} \le 10^5.
  • 1M1051 \le \mathbf{M} \le 10^5.
  • 1A_iN1 \le \mathbf{A\_i} \le \mathbf{N}, for all ii.
  • 1B_iN1 \le \mathbf{B\_i} \le \mathbf{N}, for all ii.
  • A_iB_i\mathbf{A\_i} \neq \mathbf{B\_i}, for all ii.
  • (A_i,B_i)(A_j,B_j)(\mathbf{A\_i}, \mathbf{B\_i}) \neq (\mathbf{A\_j}, \mathbf{B\_j}), for all iji \neq j.