ELVASCIS - Aya the new contestant

no tags 

A new year has started, and for Hoda this means only one thing: New acmASCIS contests will take place. This year Hoda wishes that her younger sister -Aya- would be allowed to participate with her in the contests as well. Unfortunately the higher acmASCIS council refuses this (they consider Aya too young to participate). Menna and Nour –Hoda’s friends– negotiate with the council who finally agrees that Aya can participate if and only if they give her a certain problem and she solves it without the help of Hoda, Menna or Nour. As you can see your name wasn’t mentioned by the council so please try to help Aya with her problem.

It’s a usual encryption problem.

The problem starts with some words. For every word you are considered to count the number of vowels (a, e, i, o, u) and the number of the rest of characters. After that you will match the character represented by the number of vowels with the character represented by the other number. For example, in the word ‘rozzy’, the number of vowels = 1 and the rest = 4 so b will match with e (a = 0, b = 1 ... z = 25).

If the number of vowels or the other number exceeds 25 consider their modulus only by 26. After that you will be given a text where you will change each character with its corresponding match (if it exists). If a character matches more than one character, then for every occurrence of the character it will be assigned one of its matches. For example, if c matches d then matches f and the message was ‘cycling, cycling’ then the encrypted message will be ‘dyfling, dyfling’.

Input

Your program will be tested on one or more test cases. The first line of input contains a single integer T (1 <= T <= 100) indicating the number of test cases. Each test case starts with a line L containing words separated by ‘-‘. A word is defined as a set of consecutive lower case letters (it can be empty too) and its size won’t exceed 50. The next line contains the message that Aya is asked to encrypt. Message size won’t exceed 10000.

You may assume that a character won't match another character more than once.

Output

For each test case, print "Case_#i:_X" where "X" is the encrypted message, "i" is the number of the test case (starting with 1) and "_" is a space. Each output should be printed in a separate line.

Example

Input:
2
smooth-cake-rhythm
acmascis council
smart--why
a baby-hat!!

Output:
Case #1: gemgscis eouncil
Case #2: a edey-hat!!

Explanation

Description of second example:

  • smart: b matches with e
  • Empty word: a matches with a
  • why: a matches with d

hide comments
nadstratosfer: 2018-07-23 17:21:56

Barely ACd in PyPy and that only after the silliest optimizations. Does the TL really add to the problem here?

Min_25: 2014-11-06 15:43:16

(The size of line which containing the words) < 20000. (at most)


Added by:Mohamed Ali
Date:2014-01-14
Time limit:0.100s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All
Resource:acmASCIS Level 1 Contest 2014