Adam is standing at point $(a,b)$ in an infinite 2D grid. He wants to know if he can reach point $(x,y)$ or not. The only operation he can do is to move to point $(a+b,b),(a,a+b),(a-b,b),\text{or}(a,b-a)$ from some point $(a,b)$. It is given that he can move to any point on this 2D grid, i.e., the points having positive or negative $\mbox{X}$(or $\mathbf{Y}$) co-ordinates.  

Tell Adam whether he can reach $(x,y)$ or not.

Input Format

The first line contains an integer, $\mathbf{T}$, followed by $\mathbf{T}$ lines, each containing $4$ space-separated integers i.e. $\boldsymbol{a}$, $\boldsymbol{b}$, $\boldsymbol{x}$ and $y$.  

Constraints

$1\leq T\leq1000$  
$1\leq a,b,x,y\leq10^{18}$ 

Output Format

For each test case, display YES or NO that indicates if Adam can reach $(x,y)$ or not.  

Sample Input
3
1 1 2 3
2 1 2 3
3 3 1 1

Sample Output
YES
YES
NO

Explanation

(1,1) -> (2,1) -> (2,3).

Source: hackerrank | Difficulty: EASY
Tags: Mathematics


Solutions:
t = int(input())

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)
for i in range(t):
	(a, b, x, y) = map(int, input().split())
	if gcd(a, b) == gcd(x, y):
		print('YES')
	else:
		print('NO')


def gcd(a, b):
	if a < b:
		(a, b) = (b, a)
	while b > 0:
		(a, b) = (b, a % b)
	return a
T = int(input())
for _ in range(T):
	(a, b, x, y) = [int(_) for _ in input().split()]
	if gcd(a, b) == gcd(x, y):
		print('YES')
	else:
		print('NO')


def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)
T = int(input())
for t in range(T):
	(a, b, x, y) = map(int, input().split())
	print('YES' if gcd(abs(a), abs(b)) == gcd(abs(x), abs(y)) else 'NO')


from sys import stdin
from fractions import gcd
T = int(stdin.readline())
for _ in range(T):
	(a, b, x, y) = [int(s) for s in stdin.readline().split()]
	print('YES' if gcd(a, b) == gcd(x, y) else 'NO')


from fractions import gcd
import sys
data = [int(x) for x in sys.stdin.read().split()]
for t in range(data[0]):
	(a, b, x, y) = data[t * 4 + 1:t * 4 + 5]
	d1 = abs(gcd(a, b))
	d2 = abs(gcd(x, y))
	if d1 == d2:
		print('YES')
	else:
		print('NO')


from fractions import gcd
nTest = int(input())
for i in range(0, nTest):
	(a, b, c, d) = (int(x) for x in input().split())
	print('YES' if gcd(a, b) == gcd(c, d) else 'NO')


t = int(input())

def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x
for i in range(t):
	(a, b, x, y) = map(int, input().split())
	if gcd(a, b) == gcd(x, y):
		print('YES')
	else:
		print('NO')


from fractions import gcd
T = int(input())
for _ in range(T):
	[a, b, x, y] = list(map(int, input().split()))
	if gcd(x, y) == gcd(a, b):
		print('YES')
	else:
		print('NO')


from sys import stdin as cin, stdout as cout
from math import log
from fractions import gcd
for t in range(int(cin.readline())):
	(a, b, x, y) = map(int, cin.readline().split())
	if gcd(a, b) == gcd(x, y):
		print('YES')
	else:
		print('NO')


def canon(a, b):
	if a == 0 or b == 0:
		return (0, abs(a) + abs(b))
	if abs(a) < abs(b):
		return canon(a, b % a)
	return canon(a % b, b)
T = int(input())
for i in range(T):
	(a, b, x, y) = (int(i) for i in input().split())
	print('YES' if canon(a, b) == canon(x, y) else 'NO')


def g(a, b):
	while b:
		(a, b) = (b, a % b)
	return a
T = int(input())
for test_case in range(T):
	(a, b, x, y) = (int(x) for x in input().split())
	if g(x, y) == g(a, b):
		print('YES')
	else:
		print('NO')


from fractions import gcd
t = int(input())
for i in range(t):
	(a, b, x, y) = map(int, input().split())
	temp1 = gcd(a, b)
	temp2 = gcd(x, y)
	if temp1 == temp2:
		print('YES')
	else:
		print('NO')


import sys
inp = sys.stdin.read()
inp = inp.split(sep='\n')
T = int(inp.pop(0))

def EuclidGCD(a, b):
	if a == b:
		return a
	elif a == 0 or b == 0:
		return a + b
	if a < b:
		t = b
		b = a
		a = t
	q = a // b
	r = a % b
	return EuclidGCD(b, r)
for i in range(T):
	(a, b, x, y) = map(int, inp[i].split())
	if EuclidGCD(abs(a), abs(b)) == EuclidGCD(abs(x), abs(y)):
		print('YES')
	else:
		print('NO')


import fractions, sys
T = int(sys.stdin.readline())
for _ in range(T):
	(a, b, x, y) = list(map(int, sys.stdin.readline().split()))
	(g1, g2) = (fractions.gcd(a, b), fractions.gcd(x, y))
	print('YES' if x % g1 == 0 and y % g1 == 0 and (a % g2 == 0) and (b % g2 == 0) else 'NO')


import fractions
t = int(input())
for _ in range(t):
	(a, b, x, y) = [int(i) for i in input().split()]
	print('YES' if fractions.gcd(a, b) == fractions.gcd(x, y) else 'NO')


def gcd(a, b):
	if a > b:
		(a, b) = (b, a)
	while a > 0:
		(a, b) = (b % a, a)
	return b
T = int(input())
for _ in range(T):
	(a, b, x, y) = [int(_) for _ in input().split(' ')]
	if gcd(x, y) == gcd(a, b):
		print('YES')
	else:
		print('NO')


def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)
for t in range(int(input())):
	(a, b, x, y) = [int(i) for i in input().split()]
	gcd1 = gcd(a, b)
	gcd2 = gcd(x, y)
	if gcd2 == gcd1:
		print('YES')
	else:
		print('NO')


def gcd(a, b):
	while b != 0:
		a %= b
		(a, b) = (b, a)
	return a
for _ in range(int(input())):
	(a, b, x, y) = map(int, input().strip().split())
	if gcd(a, b) == gcd(x, y):
		print('YES')
	else:
		print('NO')


def gcd(a, b):
	while b > 0:
		rem = a % b
		a = b
		b = rem
	return a
t = int(input())
while t > 0:
	t -= 1
	[a, b, x, y] = [int(k) for k in input().split()]
	GCDab = gcd(a, b)
	GCDxy = gcd(x, y)
	if GCDab == GCDxy:
		print('YES')
	else:
		print('NO')


import fractions, sys
T = int(sys.stdin.readline())
for _ in range(T):
	(a, b, x, y) = list(map(int, sys.stdin.readline().split()))
	(g1, g2) = (fractions.gcd(a, b), fractions.gcd(x, y))
	print('YES' if x % g1 == 0 and y % g1 == 0 and (a % g2 == 0) and (b % g2 == 0) else 'NO')


def GCD(x, y):
	while x % y != 0:
		(x, y) = (y, x % y)
	return y
tests = int(input())
while tests > 0:
	tests -= 1
	(x, y, a, b) = map(int, input().split())
	if GCD(x, y) == GCD(a, b):
		print('YES')
	else:
		print('NO')


test = int(input())

def gcd(a, b):
	if a % b == 0:
		return b
	else:
		return gcd(b, a % b)
for t in range(test):
	(a, b, c, d) = map(int, input().split())
	if gcd(a, b) == gcd(c, d):
		print('YES')
	else:
		print('NO')


import fractions, sys
T = int(sys.stdin.readline())
for _ in range(T):
	(a, b, x, y) = list(map(int, sys.stdin.readline().split()))
	(g1, g2) = (fractions.gcd(a, b), fractions.gcd(x, y))
	print('YES' if x % g1 == 0 and y % g1 == 0 and (a % g2 == 0) and (b % g2 == 0) else 'NO')


from fractions import gcd
n = int(input())
for i in range(n):
	(a, b, x, y) = input().split()
	(a, b, x, y) = (int(a), int(b), int(x), int(y))
	if gcd(a, b) == gcd(x, y):
		print('YES')
	else:
		print('NO')


import fractions, sys
T = int(sys.stdin.readline())
for _ in range(T):
	(a, b, x, y) = list(map(int, sys.stdin.readline().split()))
	(g1, g2) = (fractions.gcd(a, b), fractions.gcd(x, y))
	print('YES' if x % g1 == 0 and y % g1 == 0 and (a % g2 == 0) and (b % g2 == 0) else 'NO')


import fractions, sys
T = int(sys.stdin.readline())
for _ in range(T):
	(a, b, x, y) = list(map(int, sys.stdin.readline().split()))
	(g1, g2) = (fractions.gcd(a, b), fractions.gcd(x, y))
	print('YES' if x % g1 == 0 and y % g1 == 0 and (a % g2 == 0) and (b % g2 == 0) else 'NO')


def gcd(a, b):
	if a == b:
		return a
	while a > b:
		a -= b
	if a == 0:
		return b
	if b == 0:
		return a
	return gcd(b, a)
N = int(input())
for i in range(N):
	inp = [int(x) for x in input().split()]
	if gcd(inp[0], inp[1]) == gcd(inp[2], inp[3]):
		print('YES')
	else:
		print('NO')


def gcd(a, b):
	if b > a:
		swap = a
		a = b
		b = swap
	while b != 0:
		t = b
		b = a % b
		a = t
	return a
T = int(input())
for loop in range(T):
	abxy = list(map(int, input().split()))
	if gcd(abxy[0], abxy[1]) == gcd(abxy[2], abxy[3]):
		print('YES')
	else:
		print('NO')


def gcd(x, y):
	if x == y:
		return x
	if x == 0:
		return y
	if y == 0:
		return x
	while x != 0 and y != 0:
		if x > y:
			temp = x
			x = y
			y = temp
		y = y % x
	return x

def main():
	t = int(input())
	for i in range(t):
		(a, b, x, y) = input().split()
		(a, b, x, y) = (int(a), int(b), int(x), int(y))
		if gcd(a, b) == gcd(x, y):
			print('YES')
		else:
			print('NO')
main()


def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)
T = int(input())
for _ in range(T):
	(a, b, x, y) = [int(i) for i in input().split()]
	print('YES' if gcd(a, b) == gcd(x, y) else 'NO')


def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a
for _ in range(int(input())):
	(x, y, a, b) = input().split()
	if gcd(int(x), int(y)) == gcd(int(a), int(b)):
		print('YES')
	else:
		print('NO')


from fractions import gcd
for _ in range(int(input())):
	(a, b, x, y) = [int(num) for num in input().split()]
	if gcd(a, b) == gcd(x, y):
		print('YES')
	else:
		print('NO')


def gcd(x, y):
	if y == 0:
		return x
	else:
		return gcd(y, x % y)
for i in range(int(input())):
	(a, b, x, y) = input().split()
	(a, b, x, y) = (int(a), int(b), int(x), int(y))
	if gcd(a, b) == gcd(x, y):
		print('YES')
	else:
		print('NO')


def GCD(a, b):
	return GCD(b, a % b) if b else a
t = int(input())
for _ in range(t):
	(a, b, x, y) = list(map(int, input().split()))
	print('YES' if GCD(a, b) == GCD(x, y) else 'NO')


import fractions, sys
T = int(sys.stdin.readline())
for _ in range(T):
	(a, b, x, y) = list(map(int, sys.stdin.readline().split()))
	(g1, g2) = (fractions.gcd(a, b), fractions.gcd(x, y))
	print('YES' if x % g1 == 0 and y % g1 == 0 and (a % g2 == 0) and (b % g2 == 0) else 'NO')


from fractions import gcd
T = int(input())
for _ in range(T):
	(a, b, x, y) = input().split()
	print('YES') if gcd(int(a), int(b)) == gcd(int(x), int(y)) else print('NO')


from fileinput import input

def find():
	lines = input()
	n = [int(x) for x in lines[0].strip().split()][0]
	for i in range(1, n + 1):
		(a, b, c, d) = [int(x) for x in lines[i].strip().split()]
		if gcd(a, b) == gcd(c, d):
			print('YES', end='\n')
		else:
			print('NO', end='\n')

def gcd(a, b):
	if a > b:
		(a, b) = (b, a)
	while b % a != 0:
		(a, b) = (b % a, a)
	return a
find()


from fractions import gcd

def main():
	t = int(input())
	for i in range(t):
		(a, b, x, y) = map(int, input().split())
		print('YES' if gcd(a, b) == gcd(x, y) else 'NO')
main()


from fractions import gcd
for _ in range(int(input())):
	(a, b, x, y) = [int(ns) for ns in input().split()]
	if gcd(a, b) == gcd(x, y):
		print('YES')
	else:
		print('NO')


def gcd(m, n):
	(m, n) = (max(m, n), min(m, n))
	while m % n != 0:
		(m, n) = (n, m % n)
	return n
t = int(input())
for each in range(t):
	(a, b, x, y) = input().strip().split()
	(a, b, x, y) = (int(a), int(b), int(x), int(y))
	if gcd(abs(a), abs(b)) == gcd(abs(x), abs(y)):
		print('YES')
	else:
		print('NO')


from fractions import *
t = int(input())
for i in range(t):
	(a, b, c, d) = input().split()
	(a, b, c, d) = (int(a), int(b), int(c), int(d))
	if gcd(a, b) == gcd(c, d):
		print('YES')
	else:
		print('NO')


from fractions import gcd
t = int(input())
for i in range(t):
	(a, b, x, y) = list(map(int, input().split()))
	if gcd(a, b) == gcd(x, y):
		print('YES')
	else:
		print('NO')


from fractions import gcd
N = int(input())
for i in range(N):
	(a, b, x, y) = map(int, input().split())
	if gcd(a, b) == gcd(x, y):
		print('YES')
	else:
		print('NO')


import sys
from fractions import gcd
n = int(sys.stdin.readline())
for _ in range(n):
	(a, b, x, y) = [int(elem) for elem in sys.stdin.readline().split()]
	if gcd(a, b) == gcd(x, y):
		print('YES')
	else:
		print('NO')


def greatest_common_divisor(a, b):
	if a == 0 or b == 0:
		return max(a, b)
	a = abs(a)
	b = abs(b)
	while a != b:
		if a > b:
			a -= b
		else:
			b -= a
	return a

def solve(test_case):
	(a, b, x, y) = [int(i) for i in test_case.split(' ')]
	if a == b == x == y == 0:
		return 'YES'
	if a == b == 0 or x == y == 0:
		return 'NO'
	if greatest_common_divisor(x, y) == greatest_common_divisor(a, b):
		return 'YES'
	else:
		return 'NO'
num_test_cases = int(input())
for i in range(num_test_cases):
	test_case = input()
	print(solve(test_case))


def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a

def main():
	t = int(input())
	for x in range(t):
		(a, b, x, y) = list(map(int, input().split()))
		if gcd(a, b) == gcd(x, y):
			print('YES')
		else:
			print('NO')
main()


N = int(input())

def GCD(a, b):
	if b == 0:
		return a
	else:
		return GCD(b, a % b)
for x in range(N):
	temp = list(map(int, input().split()))
	a = temp[0]
	b = temp[1]
	x = temp[2]
	y = temp[3]
	if GCD(a, b) == GCD(x, y):
		print('YES')
	else:
		print('NO')


import fractions, sys
T = int(sys.stdin.readline())
for _ in range(T):
	(a, b, x, y) = list(map(int, sys.stdin.readline().split()))
	(g1, g2) = (fractions.gcd(a, b), fractions.gcd(x, y))
	print('YES' if x % g1 == 0 and y % g1 == 0 and (a % g2 == 0) and (b % g2 == 0) else 'NO')


import fractions
for i in range(int(input())):
	(a, b, x, y) = input().split()
	(a, b, x, y) = (int(a), int(b), int(x), int(y))
	if fractions.gcd(a, b) == fractions.gcd(x, y):
		print('YES')
	else:
		print('NO')


from fractions import gcd
for _ in range(int(input())):
	(a, b, x, y) = (int(k) for k in input().split(' '))
	if gcd(a, b) == gcd(x, y):
		print('YES')
	else:
		print('NO')


from fractions import gcd
t = int(input())
while t > 0:
	s = [int(i) for i in input().split()]
	m = gcd(s[0], s[1])
	n = gcd(s[2], s[3])
	if m == n:
		print('YES')
	else:
		print('NO')
	t = t - 1


import fractions
T = int(input())
for x in range(T):
	c = [int(i) for i in input().split()]
	if fractions.gcd(c[0], c[1]) == fractions.gcd(c[2], c[3]):
		print('YES')
	else:
		print('NO')


def gcd(a, b):
	if a > b:
		m = a
		n = b
	else:
		n = a
		m = b
	while n != 0:
		tmp = m
		m = n
		n = tmp % m
	return m
testCases = input()
for i in range(int(testCases)):
	inp = input()
	inp = inp.split()
	for j in range(len(inp)):
		inp[j] = int(inp[j])
	d1 = gcd(inp[0], inp[1])
	d2 = gcd(inp[2], inp[3])
	if d1 == d2:
		print('YES')
	else:
		print('NO')


def GCD(a, b):
	if a == 0:
		return b
	return GCD(b % a, a)
T = int(input())
for _ in range(T):
	[a, b, x, y] = list(map(int, input().split()))
	t1 = GCD(a, b)
	t2 = GCD(x, y)
	if t2 == t1:
		print('YES')
	else:
		print('NO')


from fractions import gcd
testcases = int(input())

def GetAnswer(a, b, x, y):
	ans = 'YES'
	if gcd(a, b) != gcd(x, y):
		ans = 'NO'
	return ans
for case in range(testcases):
	points = input()
	points = points.split()
	(a, b) = (int(points[0]), int(points[1]))
	(x, y) = (int(points[2]), int(points[3]))
	print(GetAnswer(a, b, x, y))


from fractions import gcd
for t in range(int(input())):
	(a, b, x, y) = map(int, input().split())
	if gcd(a, b) == gcd(x, y):
		print('YES')
	else:
		print('NO')


from fractions import gcd

def move(a, b, x, y):
	if a == x and b == y:
		return 1
	if a > 10 * x or b > 10 * y:
		return 0
	if a < 0 or b < 0:
		return 0
	ret = move(a, a + b, x, y)
	if ret > 0:
		return 1
	ret = move(a, a - b, x, y)
	if ret > 0:
		return 1
	ret = move(a + b, b, x, y)
	if ret > 0:
		return 1
	ret = move(a - b, b, x, y)
	return ret
size = int(input())
for i in range(size):
	(a, b, x, y) = list(map(int, input().split()))
	if gcd(a, b) == gcd(x, y):
		print('YES')
	else:
		print('NO')


def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def solve():
	(a, b, c, d) = map(int, input().split())
	if a < 0:
		a = -a
	if b < 0:
		b = -b
	if d < 0:
		d = -d
	if c < 0:
		c = -c
	if a < b:
		t = a
		a = b
		b = t
	common = gcd(a, b)
	if c < d:
		t = c
		c = d
		d = t
	second = gcd(c, d)
	if common == second:
		print('YES')
	else:
		print('NO')
n = int(input())
while n > 0:
	n = n - 1
	solve()


def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)
T = int(input())
for i in range(0, T):
	(a, b, x, y) = map(int, input().split(' '))
	if gcd(a, b) == gcd(x, y):
		print('YES')
	else:
		print('NO')


T = int(input())
while T > 0:
	line = input().split(' ')
	a = int(line[0])
	b = int(line[1])
	x = int(line[2])
	y = int(line[3])
	while a != b:
		if a > b:
			a = a - b
		else:
			b = b - a
	while x != y:
		if x > y:
			x = x - y
		else:
			y = y - x
	if a == x:
		print('YES')
	else:
		print('NO')
	T = T - 1


from fractions import gcd
T = int(input())
for t in range(0, T):
	(a, b, x, y) = [int(x) for x in input().split()]
	if gcd(a, b) == gcd(x, y):
		print('YES')
	else:
		print('NO')


t = int(input())

def nwd(a, b):
	if b > a:
		return nwd(b, a)
	return b if a % b == 0 else nwd(a % b, b)
for case in range(t):
	(a, b, x, y) = tuple(map(int, input().split()))
	print('YES' if nwd(a, b) == nwd(x, y) else 'NO')


def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a
t = int(input())
while t != 0:
	a = list(map(int, input().split()))
	if gcd(a[0], a[1]) == gcd(a[2], a[3]):
		print('YES')
	else:
		print('NO')
	t -= 1


from fractions import gcd
n = int(input())

def peter(m):
	if gcd(m[0], m[1]) == gcd(m[2], m[3]):
		print('YES')
	else:
		print('NO')
for i in range(n):
	m = input().split()
	for i in range(4):
		m[i] = int(m[i])
	peter(m)


from fractions import gcd
T = int(input())
while T:
	(a, b, x, y) = input().split()
	if gcd(int(a), int(b)) == gcd(int(x), int(y)):
		print('YES')
	else:
		print('NO')
	T = T - 1


from fractions import gcd
for _ in range(int(input())):
	(a, b, x, y) = map(int, input().split())
	if gcd(a, b) == gcd(x, y):
		print('YES')
	else:
		print('NO')


import sys
import math
from fractions import gcd
T = int(sys.stdin.readline())
if 1 <= T <= 1000:
	for i in range(T):
		C = sys.stdin.readline().split()
		C = [float(j) for j in C]
		if sum([1 <= j <= 10 ** 18 for j in C]) != 4:
			sys.stdout.write('An input is out of range!' + '\n')
			continue
		if gcd(C[0], C[1]) == gcd(C[2], C[3]):
			sys.stdout.write('YES' + '\n')
		else:
			sys.stdout.write('NO' + '\n')
else:
	sys.stdout.write('T is out of range.')


def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)
for _ in range(int(input())):
	(a, b, x, y) = map(int, input().split())
	print('YES' if gcd(a, b) == gcd(x, y) else 'NO')


def gcd(a, b):
	if b > a:
		(a, b) = (b, a)
	while True:
		r = a % b
		if r == 0:
			return b
		(a, b) = (b, r)
	return 1
ncases = int(input())
for i in range(ncases):
	(a, b, c, d) = [int(x) for x in input().split()]
	if gcd(a, b) == gcd(c, d):
		print('YES')
	else:
		print('NO')


from fractions import gcd as hcf
n = int(input(''))
for i in range(n):
	(a, b, x, y) = map(int, input('').split(' '))
	if hcf(a, b) == hcf(x, y):
		print('YES')
	else:
		print('NO')


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x

def reachable(a, b, x, y):
	if gcd(a, b) == gcd(x, y):
		return 'YES'
	else:
		return 'NO'

def main():
	n = int(input())
	for i in range(0, n):
		ar = input().split()
		a = int(ar[0])
		b = int(ar[1])
		x = int(ar[2])
		y = int(ar[3])
		print(reachable(a, b, x, y))
main()


def gcd(a, b):
	if a > b:
		remainder = a % b
		if remainder:
			return gcd(remainder, b)
		else:
			return b
	else:
		remainder = b % a
		if remainder:
			return gcd(a, remainder)
		else:
			return a

def is_accessible(a, b, x, y):
	gcd_ab = gcd(a, b)
	gcd_xy = gcd(x, y)
	if gcd_ab == gcd_xy:
		return True
	return False
nums = int(input())
for i in range(0, nums):
	(a, b, x, y) = [int(v) for v in input().split()]
	if is_accessible(a, b, x, y):
		print('YES')
	else:
		print('NO')


import fractions
T = int(input())
for _ in range(T):
	(a, b, x, y) = [int(x) for x in input().strip().split()]
	if fractions.gcd(a, b) == fractions.gcd(x, y):
		print('YES')
	else:
		print('NO')


from fractions import gcd
N = int(input())
while N:
	N -= 1
	(a, b, x, y) = map(int, input().split())
	if gcd(a, b) == gcd(x, y):
		print('YES')
	else:
		print('NO')


from fractions import gcd
for _ in range(int(input())):
	(a, b, x, y) = map(int, input().split())
	if gcd(a, b) == gcd(x, y):
		print('YES')
	else:
		print('NO')


def gcd(p, q):
	if p == 0:
		return q
	else:
		return gcd(q % p, p)
t = int(input())
while t > 0:
	t = t - 1
	abxy = input()
	abxy = abxy.split()
	a = int(abxy[0])
	b = int(abxy[1])
	x = int(abxy[2])
	y = int(abxy[3])
	c = gcd(a, b)
	d = gcd(x, y)
	if c == d:
		print('YES')
	else:
		print('NO')


from fractions import gcd
for _ in range(int(input())):
	(a, b, x, y) = [int(i) for i in input().strip().split()]
	if gcd(a, b) == gcd(x, y):
		print('YES')
	else:
		print('NO')


def GCD(a, b):
	if a % b == 0:
		return b
	else:
		return GCD(b, a % b)
T = int(input())
while T:
	(a, b, x, y) = list(map(int, input().split()))
	if GCD(a, b) == GCD(x, y):
		print('YES')
	else:
		print('NO')
	T = T - 1


def gcd(x, y):
	if y == 0:
		return x
	else:
		return gcd(y, x % y)

def main():
	for _ in range(int(input())):
		(x1, y1, x2, y2) = map(int, input().split())
		if gcd(x1, y1) == gcd(x2, y2):
			print('YES')
		else:
			print('NO')
	return 0
main()


import sys

def read_num():
	return int(sys.stdin.readline())

def read_nums():
	return list(map(int, sys.stdin.readline().split(' ')))

def get_gcd(a, b):
	if b > a:
		(a, b) = (b, a)
	while a % b != 0:
		(a, b) = (b, a % b)
	return b
n = read_num()
for i in range(0, n):
	l = read_nums()
	a = l[0]
	b = l[1]
	x = l[2]
	y = l[3]
	gcd = get_gcd(a, b)
	gcd2 = get_gcd(x, y)
	if gcd == gcd2:
		print('YES')
	else:
		print('NO')


from fractions import gcd
for t in range(int(input())):
	(a, b, x, y) = map(int, input().split())
	print('YES' if gcd(a, b) == gcd(x, y) else 'NO')


from fractions import gcd
T = int(input())
for _ in range(T):
	(a, b, x, y) = map(int, input().split())
	if gcd(a, b) == gcd(x, y):
		print('YES')
	else:
		print('NO')


def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a
n_tests = int(input())
for t in range(n_tests):
	(a, b, x, y) = map(int, input().split())
	print('YES' if gcd(abs(a), abs(b)) == gcd(abs(x), abs(y)) else 'NO')


from fractions import gcd
t = int(input())
for i in range(t):
	(a, b, x, y) = map(int, input().split())
	if gcd(a, b) == gcd(x, y):
		print('YES')
	else:
		print('NO')


from fractions import gcd
answer_dict = {True: 'YES', False: 'NO'}
for i in range(int(input())):
	p = [int(i) for i in input().split(' ')]
	if gcd(p[0], p[1]) == gcd(p[2], p[3]):
		print('YES')
	else:
		print('NO')


from fractions import gcd
n = int(input())
while True:
	try:
		line = input()
		list_no = line.split(' ')
		l = []
		for i in list_no:
			l.append(int(i))
		x = gcd(l[0], l[1])
		y = gcd(l[2], l[3])
		if x == y:
			print('YES')
		else:
			print('NO')
	except EOFError:
		break


t = int(input())

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)
for i in range(t):
	(a, b, x, y) = map(int, input().split())
	if gcd(a, b) == gcd(x, y):
		print('YES')
	else:
		print('NO')


def get_gcd(a, b):
	(a, b) = (abs(n) for n in (a, b))
	while b > 0:
		(a, b) = (b, a % b)
	return a

def is_reachable(a, b, x, y):
	return get_gcd(a, b) == get_gcd(x, y)
T = int(input())
for t in range(T):
	(a, b, x, y) = (int(n) for n in input().strip().split())
	reachable = is_reachable(a, b, x, y)
	print('YES' if reachable else 'NO')


import sys
from fractions import gcd
inputs = [line.split() for line in sys.stdin]
cleaned = []
for number in inputs[1:]:
	cord_list = []
	for item in number:
		cord_list.append(float(item))
	cleaned.append(cord_list)
for cords in cleaned:
	a = cords[0]
	b = cords[1]
	x = cords[2]
	y = cords[3]
	if gcd(a, b) == gcd(x, y):
		print('YES')
	else:
		print('NO')


def MCD(a, b):
	while b != 0:
		(a, b) = (b, a % b)
	return a
T = int(input())
for i in range(0, T):
	data = input().split()
	a = int(data[0])
	b = int(data[1])
	x = int(data[2])
	y = int(data[3])
	if MCD(a, b) == MCD(x, y):
		print('YES')
	else:
		print('NO')


from fractions import gcd
nrtests = int(input())
i = 0
while i < nrtests:
	i += 1
	line = input().strip().split(' ')
	a = int(line[0])
	b = int(line[1])
	x = int(line[2])
	y = int(line[3])
	if gcd(x, y) == gcd(a, b):
		print('YES')
	else:
		print('NO')


from fractions import gcd

def reach(a, b, x, y):
	if gcd(a, b) == gcd(x, y):
		print('YES')
	else:
		print('NO')
T = int(input())
for x in range(T):
	(a, b, x, y) = map(int, input().split())
	reach(a, b, x, y)


import math

def gcd(a, b):
	if a == 0:
		return b
	if b == 0:
		return a
	if a == b:
		return a
	if a < b:
		tmp = a
		a = b
		b = tmp
	return gcd(b, a % b)
n = int(input())
for i in range(0, n):
	(x0, y0, x1, y1) = input().split()
	(x0, y0, x1, y1) = (int(x0), int(y0), int(x1), int(y1))
	x0 = abs(x0)
	x1 = abs(x1)
	y0 = abs(y0)
	y1 = abs(y1)
	if gcd(x0, y0) == gcd(x1, y1):
		print('YES')
	else:
		print('NO')


import fractions
t = int(input().strip())
for a0 in range(t):
	(a, b, x, y) = input().strip().split(' ')
	(a, b, x, y) = [int(a), int(b), int(x), int(y)]
	if fractions.gcd(x, y) == fractions.gcd(a, b):
		print('YES')
	else:
		print('NO')


from fractions import gcd
for _ in range(int(input())):
	(a, b, c, d) = map(int, input().split())
	if gcd(a, b) == gcd(c, d):
		print('YES')
	else:
		print('NO')


import sys
from fractions import gcd
T = int(input().strip())
for i in range(T):
	[a, b, x, y] = [int(x) for x in input().split()]
	if gcd(a, b) == gcd(x, y):
		print('YES')
	else:
		print('NO')


def gcd(a, b):
	while b > 0:
		(a, b) = (b, a % b)
	return a
t = int(input().strip())
for j in range(t):
	(a, b, x, y) = [int(i) for i in input().strip().split(' ')]
	if gcd(a, b) == gcd(x, y):
		print('YES')
	else:
		print('NO')


from fractions import gcd
for _ in range(int(input())):
	(a, b, x, y) = [int(x) for x in input().split()]
	if gcd(a, b) == gcd(x, y):
		print('YES')
	else:
		print('NO')


from fractions import gcd
for _ in range(int(input())):
	(a, b, x, y) = map(int, input().split())
	print('YES' if gcd(a, b) == gcd(x, y) else 'NO')