Problem Statement:

The contest has ended, my team manged to get only 3 AC and 2 WA. If we could get all the 5 problems AC, hopefully we would have ranked in the top 10 and surely qualified to the regional contest.

here are the qualification rules:

• Every country has a maximum of K slots in the regional contest.

• Every college has a maximum of M slots in the top K ranked teams.

It's 2 hours until the closing ceremony begins. I can't wait to hear the results. So I decided to steal the results from the judges' room to know whether we qualified or not. But, I only found the final scoreboard. could you help me find the list of the qualified teams through the scoreboard and following the rules.

Input Format:

Input starts with a line containing the number of test cases (1 ≤ T ≤ 100). Then T test cases follow. each test case consists of (1 ≤ N ≤ 100) the number of teams in the scoreboard, (1 ≤ M ≤ 5) the maximum number of qualified teams per college, (1 ≤ K ≤ 20) the maximum number of qualified teams per country. Then N lines following, each line contains 2 words, team name then college name.

Output Format:

Output list of the qualified teams on the following format: "Case X:" where X is the test case number starting from 1, followed by the list of the qualified teams.

Sample Input:

1
8 1 4
TeamF U3
TeamE U2
TeamC U2
TeamD U2
TeamA U1
TeamB U1
TeamG U4
TeamH U5

Sample Output:

Case 1:
TeamF
TeamE
TeamA
TeamG