1562 - Abbreviation
Time Limit : 1 Second
Memory Limit : 128 MB
- We often use a short sequence of characters in place of some words with a very long name. For example, ACM is an
abbreviation of "Association for Computing Machinery".
Now we are using an acronymic method to get the abbreviation. An acronym is generated from a long name by capitalizing
the first letter of every word in the name and concatenating them together. There is an exception: some words are ignored
when generating the abbreviation.
These words (case insensitive) meet the following rules:
1. The common word "and", "for", and "the".
2. The word with its length less than 3, such as "a", "of", "to".
Your job is to get the abbreviation of a given string by using the acronymic method.
- The first line of the input is a positive integer T. T is the number of test cases. Each test case contains a string S with its length no greater than 100, representing the sequence of words to be abbreviated. The words consist of only alphabetic letter. There is only one space between the words, and there is no leading or trailing spaces in the string.
- For each test case, output the abbreviation of S.
- sample input
3 Association for Computer Machinery Huazhong University of Science and Technology hello
- sample output
ACM HUST H
- The 6th ACM Programming Contest of HUST