#C682. Minimum Irrigation Operations
Minimum Irrigation Operations
Minimum Irrigation Operations
You are given a rectangular field represented as a grid with n rows and m columns. In one operation, you can water all the plants in any single row or any single column. The task is to determine the minimum number of operations needed to water the entire field. It can be shown that the answer is given by \( \min(n, m) \).
For example, if the field dimensions are 2 x 3, one optimal strategy is to water the two rows (or three columns), so the minimal number of operations is min(2, 3) = 2
.
inputFormat
The first line of input contains a single integer t representing the number of test cases. Each of the next t lines contains two space-separated integers n and m indicating the number of rows and columns of the field respectively.
outputFormat
For each test case, print a single integer representing the minimum number of irrigation operations required (i.e. \( \min(n, m) \)). Each result should be printed on a new line.
## sample2
2 3
4 4
2
4
</p>