#K91267. Taco Connectivity

    ID: 37938 Type: Default 1000ms 256MiB

Taco Connectivity

Taco Connectivity

You are given a grid of size \(n \times m\) where each cell is either land (represented by a dot: .) or an obstacle (represented by a hash: #). Your task is to determine if all land cells are connected.

Two land cells are considered connected if they are adjacent horizontally or vertically. If there is a path between any two land cells that does not pass through an obstacle, then the land cells are connected. If the grid does not contain any land cell, consider it connected.

Output YES if all land cells are connected, and NO otherwise.

Note: The connectivity is defined in terms of 4-directional movement (up, down, left, right). All formulas are formatted in LaTeX. For example, the grid has dimensions \(n \times m\).

inputFormat

The first line contains two integers \(n\) and \(m\) separated by a space, representing the number of rows and columns of the grid respectively. The following \(n\) lines each contain a string of length \(m\) representing a row of the grid.

Input is read from standard input.

outputFormat

Output a single line containing either YES or NO (without quotes), where YES indicates that all land cells are connected, and NO indicates that they are not.

Output is written to standard output.

## sample
4 4
....
....
....
....
YES