#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(double);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  int t;
  int i;
  double m, n;
  scanf("%d", &t);
  for (i = 0; i < t; i++) {
    scanf("%lf%lf", &n, &m);
    printf("%.0lf\n", (ceil((n - 2) / 3)) * (ceil((m - 2) / 3)));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11e1 <main+0xb1>
lea    0xea8(%rip),%rdi
lea    -0x20(%rbp),%rsi
lea    -0x18(%rbp),%rdx
mov    $0x0,%al
call   1050 <scanf@plt>
movsd  -0x20(%rbp),%xmm0
movsd  0xe81(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  0xe6d(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1030 <ceil@plt>
mov    %eax,-0x24(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xe5c(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  0xe48(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1030 <ceil@plt>
mov    -0x24(%rbp),%esi
imul   %eax,%esi
lea    0xe4c(%rip),%rdi
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1158 <main+0x28>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xecb(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
cmpl   $0x0,0x4(%rsp)
jle    11e6 <main+0xb6>
lea    0xeb0(%rip),%r14
lea    0x8(%rsp),%r15
lea    0x10(%rsp),%r12
lea    0xea6(%rip),%r13
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1050 <scanf@plt>
movsd  0x8(%rsp),%xmm0
movsd  0xe62(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  0xe5e(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1030 <ceil@plt>
mov    %eax,%ebp
movsd  0x10(%rsp),%xmm0
addsd  0xe3d(%rip),%xmm0
divsd  0xe3d(%rip),%xmm0
call   1030 <ceil@plt>
imul   %eax,%ebp
mov    %r13,%rdi
mov    %ebp,%esi
call   1040 <printf@plt>
add    $0x1,%ebx
cmp    0x4(%rsp),%ebx
jl     1180 <main+0x50>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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