#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 */
scalar_t__ gcd(long long, long long);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, long long *, ...);
int main() {
  long long int i, j, k, n, t, x, y, a, b;
  scanf("%lld", &t);
  while (t--) {
    scanf("%lld %lld %lld %lld", &x, &y, &a, &b);
    if (gcd(a, b) == gcd(x, y))
      printf("YES\n");
    else
      printf("NO\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xec9(%rip),%rdi
lea    -0x30(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x30(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x30(%rbp)
cmp    $0x0,%rax
je     11d8 <main+0xa8>
lea    0xe8f(%rip),%rdi
lea    -0x38(%rbp),%rsi
lea    -0x40(%rbp),%rdx
lea    -0x48(%rbp),%rcx
lea    -0x50(%rbp),%r8
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x48(%rbp),%rdi
mov    -0x50(%rbp),%rsi
call   1050 <gcd@plt>
mov    %rax,-0x58(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x40(%rbp),%rsi
call   1050 <gcd@plt>
mov    %rax,%rcx
mov    -0x58(%rbp),%rax
cmp    %rcx,%rax
jne    11c7 <main+0x97>
lea    0xe57(%rip),%rdi
call   1030 <printf@plt>
jmp    11d3 <main+0xa3>
lea    0xe4b(%rip),%rdi
call   1030 <printf@plt>
jmp    1151 <main+0x21>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
lea    0xeca(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
subq   $0x1,(%rsp)
jb     11d3 <main+0xa3>
lea    0x18(%rsp),%r12
lea    0x10(%rsp),%r13
lea    0x8(%rsp),%rbx
lea    0xeab(%rip),%r14
lea    0xea1(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    0xe79(%rip),%rdi
lea    0x20(%rsp),%rsi
mov    %r12,%rdx
mov    %r13,%rcx
mov    %rbx,%r8
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x10(%rsp),%rdi
mov    0x8(%rsp),%rsi
call   1050 <gcd@plt>
mov    %rax,%rbp
mov    0x20(%rsp),%rdi
mov    0x18(%rsp),%rsi
call   1050 <gcd@plt>
cmp    %rax,%rbp
mov    %r15,%rdi
cmove  %r14,%rdi
call   1030 <puts@plt>
subq   $0x1,(%rsp)
jae    1180 <main+0x50>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%lld\00"
@.str.1 = [20 x i8] c"%lld %lld %lld %lld\00"
@.str.2 = [5 x i8] c"YES\0A\00"
@.str.3 = [4 x i8] c"NO\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
%10 = alloca i64
store i32 0, i32* %1
%11 = call i32 (i8*, i64*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64* %6)
br label %12
12: ; preds = %29, %0
%13 = load i64, i64* %6
%14 = add nsw i64 %13, -1
store i64 %14, i64* %6
%15 = icmp ne i64 %13, 0
br i1 %15, label %16, label %30
16: ; preds = %12
%17 = call i32 (i8*, i64*, ...) @scanf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i64* %7, i64* %8, i64* %9, i64* %10)
%18 = load i64, i64* %9
%19 = load i64, i64* %10
%20 = call i64 @gcd(i64 %18, i64 %19)
%21 = load i64, i64* %7
%22 = load i64, i64* %8
%23 = call i64 @gcd(i64 %21, i64 %22)
%24 = icmp eq i64 %20, %23
br i1 %24, label %25, label %27
25: ; preds = %16
%26 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %29
27: ; preds = %16
%28 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
br label %29
29: ; preds = %27, %25
br label %12
30: ; preds = %12
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"%lld\00"
@.str.1 = [20 x i8] c"%lld %lld %lld %lld\00"
@str = [3 x i8] c"NO\00"
@str.4 = [4 x i8] c"YES\00"
define i32 @main() {
%1 = alloca i64
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = bitcast i64* %1 to i8*
%7 = bitcast i64* %2 to i8*
%8 = bitcast i64* %3 to i8*
%9 = bitcast i64* %4 to i8*
%10 = bitcast i64* %5 to i8*
%11 = call i32 (i8*, i64*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64* %1)
%12 = load i64, i64* %1
%13 = add nsw i64 %12, -1
store i64 %13, i64* %1
%14 = icmp eq i64 %12, 0
br i1 %14, label %29, label %15
15: ; preds = %0, %15
%16 = call i32 (i8*, i64*, ...) @scanf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i64* %2, i64* %3, i64* %4, i64* %5)
%17 = load i64, i64* %4
%18 = load i64, i64* %5
%19 = call i64 @gcd(i64 %17, i64 %18)
%20 = load i64, i64* %2
%21 = load i64, i64* %3
%22 = call i64 @gcd(i64 %20, i64 %21)
%23 = icmp eq i64 %19, %22
%24 = select i1 %23, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @str.4, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0)
%25 = call i32 @puts(i8* dereferenceable(1) %24)
%26 = load i64, i64* %1
%27 = add nsw i64 %26, -1
store i64 %27, i64* %1
%28 = icmp eq i64 %26, 0
br i1 %28, label %29, label %15
29: ; preds = %15, %0
ret i32 0
}