UVA-11233 - Deli Deli

  • UVa Online Judge 解題結果請於 Submit 後,參閱 uHunt
  • 如果你有任何建議與指教,歡迎於下方留言一起討論喔!
  • 本題選為「20171219 大學程式能力檢定 CPE」題目。

題意概要

本題是將英文單字的複數型態變化做處理。英文單字的複數型態可以簡單列出以下規則:

  1. 字尾的最後一個字母為「y」,且倒數第二個字母為子音,則複數型態要將「y」改為「ies」結尾。
  2. 字尾的最後一個字母為「o」、「s」、「x」或是以「ch」和「sh」結尾的單字,則複數型態要加上「es」結尾。
  3. 其餘單字直接加上「s」結尾即可。 另外,有些英文單字的複數型態不是按照上述規則變化,則將要按照給定的形式去對應。本題希望你能將給定輸入的英文單字,輸出其複數型態。

Input

The first line of the input consists of two integers and (, ). The following lines contain the description of the irregular words and their plural form. Each line consists of two words separated by a space character, where the first word is the singular, the second word the plural form of some irregular word. After the list of irregular words, the following lines contain one word each, which you have to make plural. You may assume that each word consists of at most lowercase letters from the english alphabet (“a” to “z”).


Output

Print lines of output, where the i-th line is the plural form of the i-th input word.


Sample Input

3 7
rice rice
spaghetti spaghetti
octopus octopi
rice
lobster
spaghetti
strawberry
octopus
peach
turkey

Sample Output

rice
lobsters
spaghetti
strawberries
octopi
peaches
turkeys
profile-image
David Lu
Hello, I'm David Lu. I am a graduate student in Department of Computer Science at National Chiao Tung University, Taiwan. I am in the Networking and Sensing Systems (NSS) Lab at NCTU. If you have any question, please feel free to contact with me.
comments powered by Disqus