Please explain sample output for given sample input

Does Piyush starts at (0,0), also is the escape at (n-1,m-1)?

@mayankA47 hey mayank go through this link piyush and magical.