Ryana, Fardin, and Bithi are best friends. One day, they were playing with dominos and a grid. Ryana had a collection of dominos, and Fardin had a grid of size . Bithi, being the puzzle master, challenged them to find the maximum number of dominos that can be used to tile the grid, following specific rules:
You can place a domino in the grid either vertically or horizontally .
No two dominos can overlap; they must be placed in distinct grid positions.
Every domino must be entirely inside the grid.
Ryana and Fardin, being clever, quickly solved the problem. Now, it's your turn to find the maximum number of dominos that can be tiled into the grid following Bithi's rules.
The first line contains describing the number of test cases. This is followed by the description of each test case.
Next line contains two positive integers and describing the size of the grid for each test case. It is guaranteed that .
For each test case, print a single line containing the maximum number of dominos that can be placed on the given grid by following the rules.
Input | Output |
---|---|
2 3 3 1 2 | 4 1 |
A possible construction for the first test case,
A possible construction for the second test case,
You can verify that this is indeed the maximum number of dominos that can be used.