#K7301. Even Sum Path in a Grid

    ID: 33880 Type: Default 1000ms 256MiB

Even Sum Path in a Grid

Even Sum Path in a Grid

You are given a grid of integers with dimensions n × m. Your task is to determine if there exists a path from the top-left cell to the bottom-right cell such that the sum of all the numbers along the path is even. You can only move either right or down at each step.

Formally, if you denote the sum along any valid path as \( S \), you need to check whether \( S \bmod 2 = 0 \). If such a path exists, output YES; otherwise, output NO.

Note: The path must start at cell (1, 1) and end at cell (n, m), and you cannot move outside the boundaries of the grid.

inputFormat

The first line contains two integers n and m (1 ≤ n, m ≤ 1000) representing the number of rows and columns, respectively. Each of the next n lines contains m space-separated integers representing the grid.

outputFormat

Output a single line containing YES if there exists a path from the top-left to the bottom-right cell with an even sum. Otherwise, output NO.

## sample
3 3
1 2 3
4 5 6
7 8 9
NO