I tried solving 455B - A Lot of Games. I cannot understand solution for testcase 5.
4 2
aaaa
bbbb
ccccc
dumbavumba
Jury's answer : First
The output that I got is Second. During the first play, the first player writes "c", because that is the only way of winning for 1st player. So the second player is forced to continue to write "c" and eventually first player wins. And during the second iteration of the games, the second player starts because, he loses the first game resulting in his win. Is my way of understanding wrong of the problem, because for this testcase, the given output is First.








In this case the first player will want to purposely lose the first game in order to win the second game. So he will write 'a' first, and eventually will lose the first game. Then, in the second game he starts with 'c' as you described and wins. When the problem statement says that they "play optimally", that means they play in such a way that they will win the overall game if possible, not necessarily the earlier games.