Route Calculator
시간 제한2초메모리 제한512 MB
격자에서 오른쪽과 아래로만 이동하며 숫자와 +, * 기호를 이어 붙여 수식을 만들고, 그 값을 최대로 만든다.
문제
You have a grid with rows and columns. is even. We denote the cell at the -th row from the top and the -th column from the left by . In any cell , an integer between and is written if is even, and either + or * is written if is odd.
You can get a mathematical expression by moving right or down times from to and concatenating all the characters written in the cells you passed in order. Your task is to maximize the calculated value of the resulting mathematical expression by choosing an arbitrary path from to . If the maximum value is or less, print the value. Otherwise, print .
입력
The input consists of a single test case in the format below.
$H$ $W$ $a_{1,1}$ $\cdots$ $a_{1,W}$ $\ldots$ $a_{H,1}$ $\cdots$ $a_{H,W}$
The first line consists of two integers and (). It is guaranteed that is even. The following lines represent the characters on the grid. represents the character written in the cell . In any cell , an integer between and is written if is even, and either + or * is written if is odd.
출력
Print the answer in one line.