All submissions for this problem are available.
Katy Perry is coming up a new album called sequence with n songs. In accordance with the name she is trying to put it in alphabetical order. She wants to name the first song starting with the letter A, the second song starting with the letter B, and so on. However, she cannot simply come up with random words for song titles - that wouldn't make sense. For each song, she has come up with a list of acceptable names. Help Katy Perry pick an ordering of the songs and an acceptable name for each one so that each song's name starts with the correct letter of the alphabet.
The first line of input gives the number of cases, N. N test cases follow. Each one starts with n on a line by itself. The next n lines list the possible names for each of the n songs. Each line starts with ki - the number of acceptable names for song i and lists the names, separated by spaces. Each name is a non-empty string of letters. No two names will be the same, and no two names for the same song will start with the same letter.
For each test case, first output the line "Case #x:", where x is the test case number. After that, print n lines listing the n song names, each with only the first letter capitalized. There is guaranteed to be exactly one solution.
Should contain all the constraints on the input data that you may have. Format it like:
- 1 ≤ N ≤ 30
- 1 ≤ n ≤ 26
- 1 ≤ ki ≤ 26
Input: 4 3 2 Apples Oranges 1 Bananas 5 Apricots Blueberries Cranberries Zuccini Yams 1 1 ApPlEs 2 2 a b 1 axe 4 4 Aa Ba Ca Da 3 Ab Bb Cb 2 Ac Bc 1 Ad Output: Case #1: Apples Bananas Cranberries Case #2: Apples Case #3: Axe B Case #4: Ad Bc Cb Da
Note : The reference for this problem has been taken from : UVa online Judge
|Time Limit:||0.1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, PYP3, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.