#K33332. Even Path

    ID: 25064 Type: Default 1000ms 256MiB

Even Path

Even Path

You are given a matrix of integers with n rows and m columns. Your task is to determine whether there exists a path from the top-left cell (0, 0) to the bottom-right cell (n-1, m-1), such that all numbers encountered along the path are even. You can move up, down, left, or right.

Note: Both the starting and the ending cells must contain even numbers for such a path to exist.

Constraints:

  • 1 ≤ n, m ≤ 500
  • The elements of the matrix are integers.

Example:

Input:
3 3
2 4 6
3 4 2
2 2 4

Output: YES

</p>

inputFormat

The first line contains two space-separated integers n and m, representing the number of rows and columns of the matrix, respectively.

Each of the following n lines contains m space-separated integers representing the rows of the matrix.

outputFormat

Output a single line, either YES if there exists a path from (0,0) to (n-1, m-1) with all even numbers, or NO if no such path exists.

## sample
3 3
2 4 6
3 4 2
2 2 4
YES