#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int ceil(int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, int *, ...);
int main() {
  int total_test;
  int row, col;
  int ans;
  scanf("%d", &total_test);
  while (total_test-- > 0) {
    scanf("%d%d", &row, &col);
    ans = ceil((row - 2) / 3.0) * ceil((col - 2) / 3.0);
    printf("%d\n", ans);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xec4(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x8(%rbp)
cmp    $0x0,%eax
jle    11db <main+0xab>
lea    0xe9c(%rip),%rdi
lea    -0xc(%rbp),%rsi
lea    -0x10(%rbp),%rdx
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0xc(%rbp),%eax
sub    $0x2,%eax
cvtsi2sd %eax,%xmm0
movsd  0xe73(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <ceil@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%eax
sub    $0x2,%eax
cvtsi2sd %eax,%xmm0
movsd  0xe51(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <ceil@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
imul   %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe3c(%rip),%rdi
call   1040 <printf@plt>
jmp    1151 <main+0x21>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xec7(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
lea    -0x1(%rax),%ecx
mov    %ecx,0x4(%rsp)
test   %eax,%eax
jle    11f0 <main+0xc0>
lea    0xe9f(%rip),%r14
lea    0xc(%rsp),%r15
lea    0x8(%rsp),%r12
lea    0xe93(%rip),%rbx
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0xc(%rsp),%eax
add    $0xfffffffe,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  0xe5a(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <ceil@plt>
mov    0x8(%rsp),%ecx
add    $0xfffffffe,%ecx
xorps  %xmm0,%xmm0
cvtsi2sd %ecx,%xmm0
mov    %eax,%ebp
divsd  0xe35(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <ceil@plt>
imul   %eax,%ebp
mov    %rbx,%rdi
mov    %ebp,%esi
call   1040 <printf@plt>
mov    0x4(%rsp),%eax
lea    -0x1(%rax),%ecx
mov    %ecx,0x4(%rsp)
test   %eax,%eax
jg     1180 <main+0x50>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [5 x i8] c"%d%d\00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
br label %7
7: ; preds = %11, %0
%8 = load i32, i32* %2
%9 = add nsw i32 %8, -1
store i32 %9, i32* %2
%10 = icmp sgt i32 %8, 0
br i1 %10, label %11, label %28
11: ; preds = %7
%12 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* %3, i32* %4)
%13 = load i32, i32* %3
%14 = sub nsw i32 %13, 2
%15 = sitofp i32 %14 to double
%16 = fdiv double %15, 3.000000e+00
%17 = fptosi double %16 to i32
%18 = call i32 @ceil(i32 %17)
%19 = load i32, i32* %4
%20 = sub nsw i32 %19, 2
%21 = sitofp i32 %20 to double
%22 = fdiv double %21, 3.000000e+00
%23 = fptosi double %22 to i32
%24 = call i32 @ceil(i32 %23)
%25 = mul nsw i32 %18, %24
store i32 %25, i32* %5
%26 = load i32, i32* %5
%27 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %26)
br label %7
28: ; preds = %7
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [5 x i8] c"%d%d\00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%8 = load i32, i32* %1
%9 = add nsw i32 %8, -1
store i32 %9, i32* %1
%10 = icmp sgt i32 %8, 0
br i1 %10, label %11, label %30
11: ; preds = %0, %11
%12 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %3)
%13 = load i32, i32* %2
%14 = add nsw i32 %13, -2
%15 = sitofp i32 %14 to double
%16 = fdiv double %15, 3.000000e+00
%17 = fptosi double %16 to i32
%18 = call i32 @ceil(i32 %17)
%19 = load i32, i32* %3
%20 = add nsw i32 %19, -2
%21 = sitofp i32 %20 to double
%22 = fdiv double %21, 3.000000e+00
%23 = fptosi double %22 to i32
%24 = call i32 @ceil(i32 %23)
%25 = mul nsw i32 %24, %18
%26 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %25)
%27 = load i32, i32* %1
%28 = add nsw i32 %27, -1
store i32 %28, i32* %1
%29 = icmp sgt i32 %27, 0
br i1 %29, label %11, label %30
30: ; preds = %11, %0
ret i32 0
}