Wrong answer chef and glove

https://www.codechef.com/viewsolution/18876507
Here is the link of my solution. Please tell me my mistake, where i did it wrong?

Your solution does not give newlines between test cases. Also, it doesn’t even give the correct answer for the sample test case. You should try walking through the code for each test case, and see where you go wrong.

Also, why use recursion for this input and comparison of arrays? Recursion is usually use when you have 2 or more paths and you need to choose the optimal one between them.

I made some changes to your code (marked //here) and got it accepted.