TRINO - PUT TRINOMO

no tags 

Given a m × n chess board, determine the minimum number of places to be covered to make it impossible to put a L shaped trinomo on it.

e.g. In 2 × 2 chess board if you cover any 2 cells, it will be impossible to put a L shaped trinomo on it.

1 <= n, m <= 10^8

A trinomo is a L shaped object.

*
* *

where * represents a cell.

Input

T: number of test cases (T <= 5000)

Next T lines:

every line contain m, n

Output

Minimum number of cells to be covered.

Example

Input:
1
2 2

Output:
2

hide comments
Vaishali Behl: 2012-08-03 06:28:13

in case of 3 * 3 should it not be 4?
it should be 3.

Last edit: 2012-08-03 06:29:41
Pranay: 2012-08-03 05:05:06

in case of 3*3 is it 3 or 5?

NeW AcP: 2012-08-02 18:48:57

got acc. very nice problem .

Last edit: 2012-08-02 18:54:54
(Tjandra Satria Gunawan)(曾毅昆): 2012-08-02 18:48:57

@Namandeep Singh Chugh: Yes, that's right.

Naman: 2012-08-02 18:48:57

L shaped "trinomo" is any random L shape right??


Added by:praveen123
Date:2012-08-02
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:general problem