feb COOK103B test case

for the question Chef and Secret Password of COOK103B
I randomly taken two accepted solution just to understand logic then i got that solution 1 and solution 2 has the different output for the following testcase
"

1

9

abdabdabk

"
first program is giving “ab” as output
while second program is giving “a” as output
so at this situation what happens?

The correct answer is ab.
The 2nd solution is obviously wrong. Apparently, the test cases are very weak.