Game Of Strings , IIITT Woc question

Can anyone share their approach to solve this question. I am trying to solve but got WA. Click here for the question.

Thanks,
HSP

i hope this article will help you out
link:-https://www.geeksforgeeks.org/given-array-strings-find-strings-can-chained-form-circle/

https://www.codechef.com/viewsolution/29198648

Hope this helps
i tried this code even without sort in line 14 still works