TRINO - PUT TRINOMO

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

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

hide comments
2012-08-03 06:28:13 Vaishali Behl
in case of 3 * 3 should it not be 4?
it should be 3.

Last edit: 2012-08-03 06:29:41
2012-08-03 05:05:06 Pranay
in case of 3*3 is it 3 or 5?
2012-08-02 18:48:57 NeW AcP
got acc. very nice problem .

Last edit: 2012-08-02 18:54:54
2012-08-02 18:48:57 (Tjandra Satria Gunawan)(曾毅昆)
@Namandeep Singh Chugh: Yes, that's right.
2012-08-02 18:48:57 Naman
L shaped "trinomo" is any random L shape right??
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.