Problem F
Shiritori
Shiritori is a word game in which the players are required to say a word which begins with the final letter of the previous word. “Shiritori” literally means “taking the end”.
For this problem, we will play a slightly different version
of Shiritori. Keep a list
After the game ends, the program should print out
Input
The input consists of at least two lines, each line containing one word.
A word is a defined as series of english letters, each word
is composed of
There will be at most
Output
The output consists of two lines.
The first line contains all of the words in
The second line contains the all of the words in
All output should be lowercase.
Sample Input 1 | Sample Output 1 |
---|---|
shard deer word real league estranged eat tested dormant tandoori ymca improv vim x |
shard deer real league estranged dormant tandoori improv vim word eat tested ymca |
Sample Input 2 | Sample Output 2 |
---|---|
a ab abc bc cd cc cad dx xd dg areallylongwordthatslessthanonehundredcharactersasspecifiedbytheproblemstatementitsstillverylong gorillagorillagorillagorilla x |
a ab bc cd dx xd dg gorillagorillagorillagorilla abc cc cad areallylongwordthatslessthanonehundredcharactersasspecifiedbytheproblemstatementitsstillverylong |
Sample Input 3 | Sample Output 3 |
---|---|
rajio onigiri risu sumou udon x |
rajio onigiri risu sumou udon |