#C4253. Minimum Chocolate Bar Cuts

    ID: 47771 Type: Default 1000ms 256MiB

Minimum Chocolate Bar Cuts

Minimum Chocolate Bar Cuts

You are given a chocolate bar with dimensions \(M \times N\). Your task is to determine the minimum number of cuts required to split the chocolate bar into individual pieces of size \(1 \times 1\). In theory, the optimal solution is achieved by making exactly \(M \times N - 1\) cuts. This is because each cut increases the number of pieces by one, starting from a single piece.

You need to handle multiple test cases. For each test case, read the dimensions of the chocolate bar and output the minimum number of required cuts.

inputFormat

The input begins with an integer \(T\) indicating the number of test cases. Each of the following \(T\) lines contains two space-separated integers, \(M\) and \(N\), representing the chocolate bar's dimensions.

outputFormat

For each test case, output a single line containing the minimum number of cuts needed to break the \(M \times N\) chocolate bar into \(M \times N\) pieces of \(1 \times 1\).

## sample
5
2 2
2 3
1 1
3 3
1 5
3

5 0 8 4

</p>