#C9073. Maximum Cells Watered
Maximum Cells Watered
Maximum Cells Watered
You are given several test cases. In each test case, there is a rectangular grid with (N) rows and (M) columns. Your task is to determine the maximum number of cells that can be watered such that no two watered cells share the same row or the same column. In other words, for each test case the answer is (\min(N, M)) because you can water at most one cell per row and one per column.
inputFormat
The input is read from standard input (stdin). The first line contains an integer (T) representing the number of test cases. Each of the next (T) lines contains two space-separated integers (N) and (M), denoting the number of rows and columns of the grid respectively.
outputFormat
For each test case, output a single integer on a new line: the maximum number of cells that can be watered, which is (\min(N, M)). The output should be written to standard output (stdout).## sample
4
3 3
4 2
5 5
1 7
3
2
5
1
</p>