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>
/* -
Legends - A: An Array.
          S: A String Array
          n: Size of the Array A.
          x: an integer variable.
The List of Functions in the Library
1. Take input in an Integer Array - ob.ar_iin(n);
1.5 Take input in an Long Array - ob.ar_lin(n);
2. Take input in an String Array - ob.ar_sin(n);
3. Take input in an Character Array - ob.ar_cin(n);
4. Take input in an Double Array - ob.ar_din(n);
5. Print the content of an int Array - ob.print_iarr(A);
6. Print the content of an String Array - ob.print_sarr(A);
7. Print the content of a Character Array - ob.print_carr(A);
8. Print the content of a Double Array - ob.print_darr(A);
9. Get the sum of an Integer Array - ob.ar_sum(A);
10. Get the Maximum in an Array  - ob.ar_max(A);
12. Get the Minimum in an Array - ob.ar_min(A);
13. Get the Number of Digits in an Integer - ob.idigits(x);
14. Get an Integer Input - ob.iin();
15. Get a String Input - ob.sin();
*/

import java.io.*;
import java.util.*;
public class parklight
{
// Write Your Program in the main method below! 
  public static void main(String args[])throws Exception
  {
    parklight ob = new parklight();        
    int test = ob.iin(); String ans="";
    while(test-->0)
    {
        int nm[] = ob.ar_iin(2);
        int n = nm[0]; int m=nm[1];
        int sol = 0;
        if(m%2==0){
          sol = (m/2)*n;
        }
        else{
          int m1 = m-1;
          sol = (m1/2)*n;
          if(n%2!=0)
           n++;
          sol=sol+(int)(n/2);
        }
        ans=ans+sol+"\n";
    }
    ans=ans.trim();
    System.out.println(ans);
  }

  // *********** Below are the library functions, just refer the Legends at the start of the Program to use them.

  public int iin()throws Exception
  {
    DataInputStream in = new DataInputStream(System.in);
    int n = Integer.parseInt(in.readLine());
    return n;
  }
  
  public String sin()throws Exception
  {
    DataInputStream in = new DataInputStream(System.in);
    String s = in.readLine();
    return s;
  }
          
  public int[] ar_iin(int n)throws Exception
  { //Take Integer Array as Input
    DataInputStream in = new DataInputStream(System.in);
    //int n = Integer.parseInt(in.readLine());
    String line = in.readLine();
    int A[] = new int[n];
    String strs[] = line.trim().split(" ");
    for(int i=0;i<n;i++)
     A[i] = Integer.parseInt(strs[i]);
    return A;
  }

  public long[] ar_lin(int n)throws Exception
  { //Take Long Array as Input
    DataInputStream in = new DataInputStream(System.in);
    String line = in.readLine();
    long A[] = new long[n];
    String strs[] = line.trim().split(" ");
    for(int i=0;i<n;i++)
     A[i] = Long.parseLong(strs[i]);
    return A;
  }

  public String[] ar_sin(int n)throws Exception
  { //Take Integer Array as Input
    DataInputStream in = new DataInputStream(System.in);
    //int n = Integer.parseInt(in.readLine());
    String line = in.readLine();
    String strs[] = line.trim().split(" ");
    return strs;
  }

  public char[] ar_cin(int n)throws Exception
  { //Take Integer Array as Input
    DataInputStream in = new DataInputStream(System.in);
    //int n = Integer.parseInt(in.readLine());
    String line = in.readLine();
    char A[] = new char[n];
    String strs[] = line.trim().split(" ");
    for(int i=0;i<n;i++)
     A[i] = (strs[i]).charAt(0);
    return A;
  }

  public double[] ar_din(int n)throws Exception
  { //Take Integer Array as Input
    DataInputStream in = new DataInputStream(System.in);
    //int n = Integer.parseInt(in.readLine());
    String line = in.readLine();
    double A[] = new double[n];
    String strs[] = line.trim().split(" ");
    for(int i=0;i<n;i++)
     A[i] = Double.parseDouble(strs[i]);
    return A;
  }

  public void print_iarr(int A[]){
  	for(int i=0;i<A.length;i++)
  	 System.out.print(A[i]+" ");
  	System.out.println();
  }

  public void print_sarr(String A[]){
  	for(int i=0;i<A.length;i++)
  	 System.out.print(A[i]+" ");
  	System.out.println();
  }

  public void print_carr(char A[]){
  	for(int i=0;i<A.length;i++)
  	 System.out.print(A[i]+" ");
  	System.out.println();
  }

  public void print_darr(double A[]){
  	for(int i=0;i<A.length;i++)
  	 System.out.print(A[i]+" ");
  	System.out.println();
  }
  public int ar_sum(int A[])
  { //Find sum of element in an Array
    int sum=0;
    for(int i=0;i<A.length;i++)
     sum=sum+A[i];
    return sum;
  }

  public int ar_max(int A[])
  {
    int max=A[0];
    for(int i=0;i<A.length;i++)
     max=max>A[i]?max:A[i];
    return max;
  }

  public int ar_min(int A[])
  {
    int min=A[0];
    for(int i=0;i<A.length;i++)
     min=min<A[i]?min:A[i];
    return min;
  }

  public int idigits(int n)
  {
    return (int)Math.floor(Math.log10(n) + 1);
  }

  public int[] freq(String n)
  {
    n=n.toLowerCase();
    int A[] = new int[26];
    int len = n.length();
    for(int i=0;i<len;i++){
      char a = n.charAt(i);
      int temp = (int)a;
      int val = temp-97;
      A[val]++;
    }
    return A;
  }

}