#K58267. Minimum Number of Lamps
Minimum Number of Lamps
Minimum Number of Lamps
You are given T test cases. In each test case, you are given a matrix with dimensions \(N \times M\). Your task is to determine the minimum number of lamps required to illuminate every cell in the matrix. A lamp, when placed, can illuminate an entire row or an entire column. It turns out that the optimal strategy is to place lamps along the larger dimension, so the minimum number of lamps needed is \(\max(N, M)\).
Input Format: The first line of input contains an integer \(T\), the number of test cases. Each of the following \(T\) lines contains two integers \(N\) and \(M\), representing the dimensions of the matrix.
Output Format: For each test case, output a single line containing the minimum number of lamps required.
Example:
Input: 3 3 3 5 7 1 6</p>Output: 3 7 6
inputFormat
The first line contains an integer \(T\), denoting the number of test cases. Each of the next \(T\) lines contains two space-separated integers \(N\) and \(M\), representing the number of rows and columns of the matrix.
outputFormat
For each test case, print a single integer that represents the minimum number of lamps required to illuminate every cell in the matrix. The answer for each test case should be printed on a new line.
## sample1
3 3
3
</p>