Programming contests

Magas szintű programozási nyelvek 1, egyéni verseny, 2015. április 12.

April 12, 2015 10:00 AM – April 12, 2015 3:00 PM

Decoding the Message

Chico and Maria are relatives who live in different towns. As they both live in a rural area, it is very difficult for them to keep in touch. One way they found to overcome their communication problem is to send messages through their parents who often visit each other.

The point is that Chico and Maria do not want their parents to read their messages, so they decided to create a secret code for the messages. The code is not very sophisticated, but you should keep in mind that Chico and Maria are just children.

In general, the meaning of a message is based on a letter of each word in it. The decoded message is formed by taking the first letter of the first word, the second letter of the second word, and so on. If a word does not have enough letters, the following word should be used. For example, if you are analyzing the third word, you should consider its third letter, but if it has only two letters, then you should try to form a decoded word with the third letter of the fourth word.

When the end of a line is reached, you should finish decoding the current word and start to form the next one from the first letter of the first word in the next line.

Your task is to translate a message according to Chico and Maria's secret code.

Input Specification

The first line of the input gives the number of test cases, T (1 ≤ T ≤ 30), then there is a blank line before the first test case. Each test case represents a message, which is composed of N lines (1 ≤ N ≤ 100), and each line is composed of M words (1 ≤ M ≤ 30). Two words in the same line are separated by one or more whitespaces. A word is formed by the letters AZ and az and has at most 30 letters. The only symbols that appear in the input are alphabetic letters and whitespaces. There will be a blank line after each message.

Output Specification

For each test case, you must print the number of the test case and each word of the decoded message, one per line (look at the sample output for the exact format). You must print a blank line between consecutive test cases.

Sample Input

  1. 2
  2. Hey good lawyer
  3. as I previously previewed
  4. yam does a soup
  5. First I give money to Teresa
  6. after I inform dad of
  7. your horrible soup
download as text file

Output for Sample Input

  1. Case #1:
  2. How
  3. are
  4. you
  5. Case #2:
  6. Fine
  7. and
  8. you
download as text file
University of Debrecen; Faculty of Informatics; v. 03/01/2019