Mario and Princess Peach

Limits: 2s, 512 MB

The world of Mario can be imagined as 2D grid of row N and column M containing a total of N×M cell. Mario starts from top-leftmost cell and Princess Peach is located at bottom-rightmost cell.

This is a companion discussion topic for the original entry at