#C711. Uniform Row Toggle
Uniform Row Toggle
Uniform Row Toggle
You are given a grid with (N) rows and (M) columns consisting of binary digits (0 or 1). You are allowed to perform any number of toggle operations on an entire row. A toggle operation is defined as flipping every element in the row (i.e., turning 0s into 1s and 1s into 0s). However, note that toggling a row does not change the uniformity of that row. In other words, if a row is not already uniform (all elements identical), toggling it will not make it uniform. Your task is to determine if every row in the grid is uniform. If every row is uniform, output "YES"; otherwise, output "NO".
inputFormat
The input is read from standard input (stdin). The first line contains an integer (T) denoting the number of test cases. Each test case begins with a line containing two integers (N) and (M), representing the number of rows and columns, respectively. Then follow (N) lines, each containing (M) space-separated integers (each either 0 or 1) representing the cells of the grid.
outputFormat
For each test case, print a single line to standard output (stdout) containing "YES" if every row in the grid is uniform (i.e. every element in the row is the same), or "NO" otherwise.## sample
2
2 3
0 1 0
1 0 1
2 2
1 1
0 1
NO
NO
</p>