
Iva is a big fan of candy! In front of her is an
In every cell, there is either an obstacle or a piece of candy with a number written
on it. Iva will eat all the candy she gets her hands on during her trip (including
the candy in the first and last cell) and then multiply all the numbers on them.
Iva knows her favourite number is
Input Specification
The first line contains two integers
In each of the next
Output Specification
Print a single line with the required number from the task.
Constraints
Subtask | Points | Constraints |
---|---|---|
No additional constraints. |
Sample Input 1
2 2
3 2
1 4
Sample Output 1
2
Sample Input 2
3 6
5 2 -1
7 3 6
-1 3 1
Sample Output 2
3
Explanation for Sample 2
There are three possible paths such that the product is divisible by
Comments