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

문제

John participates in an annual walking competition called Walktober. The competition runs for a total of $\mathbf{N}$ days and tracks the daily steps of the participants for all the $\mathbf{N}$ days. Each participant will be assigned a unique ID ranging from $1$ to $\mathbf{M}$ where $\mathbf{M}$ is the total number of registered participants. A global scoreboard is maintained tracking the daily steps of each participant.

John is determined to win Walktober this year and his goal is to score the maximum daily steps on each of the $\mathbf{N}$ days among all the participants. Having participated in Walktober last year as well, he wanted to know how many steps he fell short of in achieving his goal. Given the previous year scoreboard, calculate the minimum additional steps he needed over his last year score in order to achieve his goal of scoring the maximum daily steps every day.

입력

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

The first line of each test case contains three integers $\mathbf{M}$, $\mathbf{N}$, and $\mathbf{P}$ denoting the total number of participants, the total number of days the competition runs, and the last year participant ID of John.

The next $\mathbf{M}$ lines describe the scoreboard of the previous year and contains $\mathbf{N}$ integers each. The $j$-th integer of the $i$-th line denotes the step count $\mathbf{S_{i,j}}$ of the participant with ID $i$ on the $j$-th day of the competition.

출력

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 total additional steps needed by John to achieve his goal.

제한

  • $1 \le \mathbf{T} \le 100$.
  • $1 \le \mathbf{N} \le 31$.
  • $1 \le \mathbf{S_{i,j}} \le 60000$ for all $i$ and $j$.
  • $1 \le \mathbf{P} \le \mathbf{M}$.

Test Set 1 (4점)

시간 제한: 20 초

  • $\mathbf{M} = 2$.

Test Set 2 (6점)

시간 제한: 40 초

  • $2 \le \mathbf{M} \le 1000$.

예제 입력 1

1
2 3 1
1000 2000 3000
1500 1500 3000

예제 출력 1

Case #1: 500

In the Sample Case, the competition ran for $3$ days and the participant ID of John was $1$. On day $1$, as the other participant has more steps, John needs $500$ additional steps. On the rest of the days, as John already has the maximum steps, he needs no additional steps. So, he needs a total of $500$ additional steps to achieve his goal.

예제 입력 2

2
3 2 3
1000 2000
1500 4000
500 4000
3 3 2
1000 2000 1000
1500 2000 1000
500 4000 1500

예제 출력 2

Case #1: 1000
Case #2: 2500

In the Sample Case #1, the competition ran for $2$ days and the participant ID of John was $3$. He needs an additional $1000$ steps on day $1$ and $0$ steps on day $2$ to achieve his goal. So, he needs a total of $1000$ additional steps to achieve his goal.

In the Sample Case #2, the competition ran for $3$ days and the participant ID of John was $2$. He needs an additional $0$ steps on day $1$, $2000$ steps on day $2$, and $500$ steps on day $3$ to achieve his goal. So, he needs a total of $2500$ additional steps to achieve his goal.

채점 및 기타 정보

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