What is the mistake?

Code-:Submission #122179063 - Codeforces
Question-:Problem - 4C - Codeforces

Consider the test input:

4
abc
def
abc
def