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 1. For example, park with n=m=2 has 12 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).

<image> The park sizes are: n=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.

Input

The first line contains a single integer t (1 ≤ t ≤ 10^4) — the number of test cases in the input. Then t test cases follow.

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

Output

Print t 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.

Example

Input


5
1 1
1 3
2 2
3 3
5 3


Output


1
2
2
5
8

Note

Possible optimal arrangement of the lanterns for the 2-nd test case of input data example: <image>

Possible optimal arrangement of the lanterns for the 3-rd test case of input data example: <image>
import sys
import heapq
import re
from itertools import permutations
from bisect import bisect_left, bisect_right
from collections import Counter, deque
from fractions import gcd
from math import factorial, sqrt, ceil,log2,fabs
from functools import lru_cache, reduce
import math
INF = 1 << 60
MOD = 1000000007
sys.setrecursionlimit(10 ** 7)

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
 
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
 
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
 
        if x == y:
            return
 
        if self.parents[x] > self.parents[y]:
            x, y = y, x
 
        self.parents[x] += self.parents[y]
        self.parents[y] = x
 
    def size(self, x):
        return -self.parents[self.find(x)]
 
    def same(self, x, y):
        return self.find(x) == self.find(y)
 
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
 
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]
 
    def group_count(self):
        return len(self.roots())
 
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
 
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
 
def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True
 
 

def warshall_floyd(d, n):
  
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d
 
 

def dijkstra_heap(s, edge, n):
    
    d = [10**20] * n
    used = [True] * n 
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
       
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
 
    if temp!=1:
        arr.append([temp, 1])
 
    if arr==[]:
        arr.append([n, 1])
 
    return arr
 

def lcm(x, y):
    return (x * y) // gcd(x, y)
 

def lcm_list(numbers):
    return reduce(lcm, numbers, 1)
 

def gcd_list(numbers):
    return reduce(gcd, numbers)

def eratosthenes(limit):
    A = [i for i in range(2, limit+1)]
    P = []
 
    while True:
        prime = min(A)
        
        if prime > sqrt(limit):
            break
            
        P.append(prime)
            
        i = 0
        while i < len(A):
            if A[i] % prime == 0:
                A.pop(i)
                continue
            i += 1
            
    for a in A:
        P.append(a)
            
    return P
 
def permutation_with_duplicates(L):
 
    if L == []:
        return [[]]
 
    else:
        ret = []
 
       
        S = sorted(set(L))
 
        for i in S:
 
            data = L[:]
            data.remove(i)
 
            for j in permutation_with_duplicates(data):
                ret.append([i] + j)
 
        return ret
def check(a,b,c,d,m):
    if a*(m**3) + b*(m**2) + c*m +d ==0:
        return True
    else:
        return False

def f1(a,b,c,d):
    l=-1001
    h=1000
    eps=10**(-6)
    while fabs(l-h)>eps:
        m=(l+h)/2
        if a*(m**3) + b*(m**2) + c*m +d>0:
            l=m
        elif (a*(m**3) + b*(m**2) + c*m +d)==0:
            return m
        else:
            h=m
    return l
def f(a,b,c,d):
   
    l=-1001
    h=1000
    eps=10**(-6)
    a=False
    b=False
    while fabs(l-h)>eps:
        
        m=(l+h)/2
        if a*(m**3) + b*(m**2) + c*m +d<0:
            a=True
            l=m
        elif (a*(m**3) + b*(m**2) + c*m +d)==0:
            return m
        else:
            h=m
            b=True
        if a and b:
            return m
            
    return l 
   
    


def BinarySearch(a, x): 
    i = bisect_left(a, x) 
    if i: 
        return (i-1) 
    else: 
        return -1
def BinarySearch1(a, x): 
    i = bisect_right(a, x) 
    if i != len(a)+1 and a[i-1] == x: 
        return (i-1) 
    else: 
        return -1
 
t = int(input())
for i in range(t):
    a,b=map(int,input().split())
    if a*b%2==0:
        print(a*b//2)
    else:
        q=(a-1)*b//2
        q+=b//2 + 1
        s=(b-1)*a//2
        s+=a//2 + 1
        print(min(q,s))

