// Arup Guha
// 4/26/2019
// Solution to 2019 FHSPS Playoff Problem: King

import java.util.*;

public class king {

	public static void main(String[] args) {
		
		Scanner stdin = new Scanner(System.in);
		int numCases = stdin.nextInt();
		
		// Process each case.
		for (int loop=0; loop<numCases; loop++) {
			
			// Get case.
			int r = stdin.nextInt();
			int c = stdin.nextInt();
			
			// Each king can stake out a 3 x 3 area, so count the fewest 3 x 3 areas
			// that can completely cover the board.
			System.out.println( ((r+2)/3)*((c+2)/3) );
		}
	}
}