#P1638. Park Lighting

Park Lighting

题目描述

Due to the coronavirus pandemic, city authorities obligated citizens to keep a social distance. The mayor of the city Semyon wants to light up Gluharniki park so that people could see each other even at night to keep the social distance.

The park is a rectangular table with n rows and m columns, where the cells of the table are squares, and the boundaries between the cells are streets. External borders are also streets. Every street has length 11. For example, park with n=m=2n=m=2 has 1212 streets.

You were assigned to develop a plan for lighting the park. You can put lanterns in the middle of the streets. The lamp lights two squares near it (or only one square if it stands on the border of the park).

The park sizes are: n=4,m=5n=4, m=5. The lighted squares are marked yellow. Please note that all streets have length 1. Lanterns are placed in the middle of the streets. In the picture not all the squares are lit.

Semyon wants to spend the least possible amount of money on lighting but also wants people throughout the park to keep a social distance. So he asks you to find the minimum number of lanterns that are required to light all the squares.

输入格式

The first line contains a single integer t(1t104)t (1≤t≤104) — the number of test cases in the input. Then tt test cases follow.

Each test case is a line containing two integers n,m(1n,m104)n, m (1≤n,m≤104) — park sizes.

输出格式

Print tt answers to the test cases. Each answer must be a single integer — the minimum number of lanterns that are required to light all the squares.

样例

5 
1 1 
1 3 
2 2 
3 3 
5 3
1 
2 
2 
5 
8

提示

Possible optimal arrangement of the lanterns for the 22-nd test case of input data example:

Possible optimal arrangement of the lanterns for the 33-rd test case of input data example:


By ZenF1sh