Tom and Jerry Game Solution

I have written the code in python
Here are the details

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

please guide me how to improve my code

I’m not quite on time. But if you’re still here, tell me if you managed to correct your mistakes and how exactly?