This page is still under construction.

Parts of this page are still being built. What you see may change.

Country Leader

Time limit5sMemory limit512 MB

Summary
For each test case, pick the name with the most distinct letters, breaking ties by lexicographic order where a space sorts before any letter.
Level

Easy2 of 10

Topics
String, Sorting, Implementation, Hash map
Solved
No attempts yet

Problem

The constitution of a country says that the leader is the person whose name contains the greatest number of different letters. The country writes names with the uppercase letters A through Z, and a space inside a name does not count as a letter. For example, GOOGLE contains four different letters: E, G, L and O. APAC CODE JAM contains eight. If those two people are the whole country, the leader is APAC CODE JAM.

If several people have the same number of different letters, the leader is the one whose name comes first in alphabetical order. Names are compared character by character, and a space comes before every letter. For example, A AB C and DEF both contain three different letters, and A AB C comes first, so A AB C is the leader.

Given the names of all citizens, find the leader.

Input

The first line contains the number of test cases TT. Each test case begins with a line containing the population NN. The next NN lines each contain the name of one citizen.

Output

For each test case, print one line in the form Case #x: y, where xx is the test case number starting from 1 and yy is the name of the leader.

Constraints

  • 1≤T≤1001 \le T \le 100
  • 1≤N≤1001 \le N \le 100
  • Each name is at most 20 characters long and consists only of the uppercase letters A through Z and spaces.
  • Every name starts and ends with a letter, so every name contains at least one letter.

Examples1

  1. Example 1

    Input
    2
    3
    ADAM
    BOB
    JOHNSON
    2
    A AB C
    DEF
    
    Expected output
    Case #1: JOHNSON
    Case #2: A AB C