Easy Beginners Problems > Ad-hoc

Once upon a time there was a famous person named Saadat Chowdhury. He is so much intelligent. One day he invented an algorithm which become popular within few days. His algorithm works on encryption decryption mechanism. For Example, "**LLEELLEELLEELFFTTFTTFHFHIHIM**" **2** **4 3** This secret message without double quotation if passed into his algorithm than it generates the original message of exactly two words of length 4 and length 3. And original message is **LEFT HIM**. (The original message always contains distinct characters) Which means that **largest character occurrences** will be the first character than the second largest one will be the second one and so on. And first **four characters** will makes a word and then **a space** than the last **three characters** makes second word. **If two or more different characters number of occurrence become same than print the characters in alphabetically ascending order**. One day Saadat give few encrypted message to his student and asked him what will be the original message. Now your task is to help the student to decrypt the secret message. ***Note: It is assured that each encrypted message has exactly one valid solution.*** Input: ------ The first line will contain the test case **T(T<=10)** and the next line will contain an encrypted message **S**. The message will contain uppercase english letters and the length of the secret message does not exceed **400 characters**. And the next line contain a number **N(1<=N<=10)** which is the total number of words in the **original message**. And the next line will contain **ith** word length **Li**. For more specifications see the sample input. Output: ------- The output will be start by the case number like "**Case x:** " without double quotation where **x** denotes the case number. And after that the original message of the encrypted message according to the method mentioned in problem description. For more specifications see the sample output. Sample Input ------------ 2 LLEELLEELLEELFFTTFTTFHFHIHIM 2 4 3 HHHHHHHIIIII 1 2 Sample Output ------------- Case 1: LEFT HIM Case 2: HI

Mir Lutfur Rahman