Submit Best Submissions All Submissions

308. Enter The Contest


Problem Statement:
During the ACPC 2013, the contest floor was divided into 26 blocks. Each block contained a set of tables for teams. Loubna Benguit (Maghreb Area Coordinator at ACM ACPC Arab Collegiate Programming Contest, Publicity Committee Chair at IEEE ENSIAS Student Branch. and Vice Chair of Executive Committee at ACM-Morocco) was responsible for making the teams enter the contest floor. To start the contest on time, she needed to estimate the total time for all the teams to reach their table. The time needed for a team to reach their table depends on which block it's in, which is equal to (in minutes) the row number of the block plus the column number of the block.



For example: a team can reach their table located in block A in 2 minutes and their table in block Z in 7 minutes. For each team in the contest, you know the block in which their table is located, please help Loubna to compute the time needed for all the teams to reach their tables to be able to start the contest on time. Remember only one team can be moving on the contest floor at a time.


Input Format:
Your program will be tested on one or more test cases. The first line of the input will be a single integer T, the number of test cases (1 ≤ T ≤ 100). Followed by T lines, each line is a test case which consists of C characters denoting the the blocks for each team as described in the problem statement (1 ≤ C ≤ 106).


Output Format:
For each test case print a single line containing "Case n:" (without the quotes) where n is the test case number (starting from 1) followed by a space then X which is the the time needed to all teams to reach their blocks.


Sample Input:
4 AZB AAA ZJF ABCDEFGHIJKLMNOPQRSTUVWXYZ


Sample Output:
Case 1: 12 Case 2: 6 Case 3: 17 Case 4: 157


Notes:
In the first test-case the first team needs 2 minutes to reach block A, the second team needs 7 minutes to reach block Z and the last team needs 3 minutes to reach block B, so the total time is 12.





Added by: ahmed_aly
Added at: 2014-10-25 09:00:00 UTC
Time Limit: 3 seconds
Partial score: No
Source:ACM Oman Collegiate Programming Contest 2014