Problem in Understanding the Question

Can the test case that is given in the question be explained in detail, I am unable to figure out how Piyush moves to the new row and which direction he moves in each row.
And what is finally expected in the output?
What does this mean “Assume that Piyush can shift immediately from last of one row to the start of next one without loss of any strength, help out Piyush to escape the park”.

Thanks in Advance !!

@sagnik.pal2017 here is the dry link of the sample one you can refer to
this.

Hey, thanks that was a good explanation, I understood the problem. I have now solved it.

@sagnik.pal2017 happy coding