you give m x n matrix grid initially locate topleft corner 0 0 step right matrixamong possible path start topleft corner 0 0 end bottomright corner m 1 n 1 find path maximum nonnegative product the product path product integer grid cell visit pathreturn maximum nonnegative product modulo 109 7 if maximum product negative return 1notice modulo perform get maximum product example 1input grid 123233332output 1explanation it possible nonnegative product path 0 0 2 2 return 1example 2input grid 121121341output 8explanation maximum nonnegative product show 1 1 2 4 1 8example 3input grid 1304output 0explanation maximum nonnegative product show 1 0 4 0 Constraintsm gridlengthn gridilength1 m n 154 gridij 4