Ques :Piyush and Magical park

In the sample input, in the last row a # is encountered so how will he be able to reach home. Also please explain the max strength gathered in the sample input.

Sample input n,m=4,4
so his home is at (5,0) next of last row
when he encounters # on (4,2) it automatically reach home as on encounter # u got switched to first element of next row.

Maximum strength meaning the positive health due to * .
If u encounter this in the first column , it means u add 5 and if u encounter * on column other than first column , it means u got 4 ( 5-(1 loss due to movement on each step))
Hope u get it.
Hit like if u get it.