F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Kong Ming Qi

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 637    Accepted Submission(s): 250


Problem Description
According to legend, Kongming Chess is an intellectual game invented by Kongming during the Three Kingdoms period. In this problem, we make a slight modification to Kongming Chess. The game is played on an $(n+2) \times (m+2)$ chessboard, and there is one chess piece on each of the $n \times m$ positions in the middle of the chessboard.



The rules of Kongming Chess are as follows: Each time, you can choose one chess piece and then choose one of the four directions: up, down, left, or right. Move the chess piece one grid away in the chosen direction from its original position. In addition to the above requirement, the following conditions must be satisfied: There must be a chess piece on the intermediate position between the original position and the target position, and the target position must not have a chess piece. All positions must be on the chessboard.

After the move, the chess piece on the intermediate position is taken away. After each move, one chess piece will be removed from the chessboard. Now, we need you to solve a problem: Given n and m, what is the minimum number of chess pieces left on the chessboard?
 

Input
The first line contains a positive integer, $T$, where $1 ≤ T ≤ 100$, representing the number of query sets.

Next, there will be T lines, each representing a query. Each line contains two positive integers, $n$ and $m$, where $1 ≤ n, m ≤ 65$.
 

Output
For each test case, output one line containing an integer representing the answer.
 

Sample Input
2 1 2 2 3
 

Sample Output
1 2
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-25 08:00:58, Gzip enabled