Simona dreams of uncountable riches. She is offered to play a game for a big prize.
Simona will be placed in cell of a grid of size filled with positive integers. She must reach cell . To do this, she is allowed to repeatedly move from her current cell to any other cell or , such that . For each such move, Simona will receive reward coins , where , are her new coordinates and is a constant cost fixed before the start of the journey. Note that if the expression evaluates to a negative number, Simona will lose coins. Note also that it is possible to end the game with a negative number of coins.
Help Simona determine the maximum number of coins she can finish the game with.