#Lutece0689. Kennethsnow's Bias
Kennethsnow's Bias
Migrated from Lutece 689 Kennethsnow's Bias
All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.
Description
I loosed, at random, vows, complaints: and you,
you’ll see these wandering birds come home to roost.
You’ll see in this letter I was - take it, you must -
more eloquent, as well, the less I was sincere!
Take it, and be done!
——CYRANO DE BERGERAC, by Edmond Rostand
Our lovely young girl zplinti1 is playing a game with bearchild. To play the game, they have to find a blackboard and a single piece of paper.
First of all, they write a string on the blackboard. After that, they take turns playing. Zplinti1 always moves first. In each step:
- The player chooses a letter either from the leftmost or the rightmost position of the string, and erases that letter.
- The player then write down the string remains on the blackboard on a paper.
When the blackboard is clean, the game is over.
But who is the winner? Luckily, we have kennethsnow as a judge. He has already written some words in secret and calls those words magic word
. When the game finishes, if zplinti1 has ever written a magic word on paper, he will win, otherwise bearchild wins.
You see, if both of them play this game fairly, poor zplinti1 will hardly have a chance to win… But kennethsnow loves zplinti1, he told her those magic words in advance – in secret, of course! But bearchild is such a clever animal, how could they cheat under his eyes?
So the truth is, both players know those magic words in advance, so we decided to let you, the clever programmers, know those words too. Given the original string s and some magic words, who will be the winner of the game?
Input
The first line of input contains a number , indicating the number of cases().
For each case, the first line is a string s, with length no more than . The second line is a number , which is the number of magic words. Then lines comes, each with a string. They are the magic strings.
All the strings contains lowercase letters from a
to z
only. The total length of all magic strings in one case will be no more than .
Output
For each case, output Case #i:
first. ( is the number of the test case, from to ). Then output the name of the winner. See sample output for more details.
Samples
2
abcde
2
abc
bcde
aaaaa
1
nya
Case #1: zplinti1
Case #2: bearchild
Resources
11th UESTC Programming Contest Preliminary