Piyush and Magical Park, Unable to pas one test case

link :https://ide.codingblocks.com/s/145381

above is link to my code of above question please tell which corner cases I am leaving out

hi divya
whenever the engery is 0 u have to exit from both the loop