Why does my solution fails? DEMENTIA Min-max string problem

Can anybody provide a test case for which my solution fails?
My solution: https://www.codechef.com/viewsolution/36689192

Even if your solution is correct, you are sorting the whole array of strings every time you get a query of type 2 or 3, bound to get TLE