Problem F
Thore's self-esteem

Input
The first line of the input contains a single number
Then follows
Each name only contains characters from the set
Exactly one name is “ThoreHusfeldt” in the input.
Output
The output is a single line. If “ThoreHusfeldt” is first on the scoreboard, output “Thore is awesome”. If another person, with a name containing “ThoreHusfeld”(note: no trailing “t”) as a prefix is above Thore, output “Thore sucks”.
Otherwise output the smallest prefix that uniquely determines Thore on the scoreboard from the top. In other words: find the smallest prefix of “ThoreHusfeldt” that no-one above “ThoreHusfeldt” shares.
Sample Explanation
In Sample Input
Sample Input 1 | Sample Output 1 |
---|---|
2 ThoreTiemann ThoreHusfeldt |
ThoreH |
Sample Input 2 | Sample Output 2 |
---|---|
2 ThoreHusfeldt JohanSannemo |
Thore is awesome |
Sample Input 3 | Sample Output 3 |
---|---|
2 ThoreHusfeldter ThoreHusfeldt |
Thore sucks |
Sample Input 4 | Sample Output 4 |
---|---|
2 JohanSannemo ThoreHusfeldt |
T |