you give table size n time m we consider table row number 1 n column number leave right 1 m we denote cell ith row jth column j in cell j write number 1 cdot m j a_ij 1 cdot m jA turtle initially stand cell 1 1 wants come cell n m from cell j step cell 1 j j 1 exist a path sequence cell adjacent sequence cell follow satisfie turtle reach cell second cell step a cost path sum number write cell path for example n 2 m 3 table look show the turtle follow path 1 1 rightarrow 1 2 rightarrow 1 3 rightarrow 2 3 the cost way equal a_11 a_12 a_13 a_23 12 on hand path 1 1 rightarrow 1 2 rightarrow 2 2 rightarrow 2 1 1 1 rightarrow 1 3 incorrect path turtle can not step 2 2 rightarrow 2 1 second path can not step 1 1 rightarrow 1 3you ask tell turtle minimal possible cost path cell 1 1 cell n m please note cell 1 1 n m way