You are given two integers $a$ and $b$. You may perform any number of operations on them (possibly zero).

During each operation you should choose any positive integer $x$ and set $a := a - x$, $b := b - 2x$ or $a := a - 2x$, $b := b - x$. Note that you may choose different values of $x$ in different operations.

Is it possible to make $a$ and $b$ equal to $0$ simultaneously?

Your program should answer $t$ independent test cases.


-----Input-----

The first line contains one integer $t$ ($1 \le t \le 100$) — the number of test cases.

Then the test cases follow, each test case is represented by one line containing two integers $a$ and $b$ for this test case ($0 \le a, b \le 10^9$).


-----Output-----

For each test case print the answer to it — YES if it is possible to make $a$ and $b$ equal to $0$ simultaneously, and NO otherwise.

You may print every letter in any case you want (so, for example, the strings yEs, yes, Yes and YES will all be recognized as positive answer).


-----Example-----
Input
3
6 9
1 1
1 2

Output
YES
NO
YES



-----Note-----

In the first test case of the example two operations can be used to make both $a$ and $b$ equal to zero:  choose $x = 4$ and set $a := a - x$, $b := b - 2x$. Then $a = 6 - 4 = 2$, $b = 9 - 8 = 1$;  choose $x = 1$ and set $a := a - 2x$, $b := b - x$. Then $a = 2 - 2 = 0$, $b = 1 - 1 = 0$.

Source: codeforces | Difficulty: EASY
Tags: Sorting

Mathematics


Solutions:
def fastio():
	import sys
	from io import StringIO
	from atexit import register
	global input
	sys.stdin = StringIO(sys.stdin.read())
	input = lambda : sys.stdin.readline().rstrip('\r\n')
	sys.stdout = StringIO()
	register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	z = 2 * min(a, b) - max(a, b)
	if z < 0:
		print('NO')
	elif z % 3 == 0:
		print('YES')
	else:
		print('NO')


import sys
reader = (map(int, s.split()) for s in sys.stdin)
(t,) = next(reader)
for _ in range(t):
	(a, b) = next(reader)
	cond = 2 * a >= b and 2 * b >= a and (not (a + b) % 3)
	print('YES' if cond else 'NO')


for i in range(int(input())):
	(a, b) = map(int, input().split())
	print('YeS' if (a + b) % 3 == 0 and max(a, b) <= 2 * min(a, b) else 'No')


from sys import stdin

def solve():
	for _ in range(int(stdin.readline())):
		(a, b) = map(int, stdin.readline().split())
		a1 = min(a, b)
		b1 = max(a, b)
		k = 2 * b1 - a1
		if k % 3 == 0:
			if a1 - k // 3 >= 0 and b1 - 2 * (k // 3) >= 0:
				print('YES')
			else:
				print('NO')
		else:
			print('NO')
solve()


n = int(input())
results = []
for i in range(n):
	vals = input().split()
	a = int(vals[0])
	b = int(vals[1])
	x = 2 * a - b
	y = 2 * b - a
	if x % 3 == 0 and y % 3 == 0 and (x >= 0) and (y >= 0):
		results.append('YES')
	else:
		results.append('NO')
for result in results:
	print(result)


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	if a == b:
		print('YES' if a % 3 == 0 else 'NO')
		continue
	if a < b:
		(a, b) = (b, a)
	x = a - b
	if a - 2 * x >= 0 and b - x >= 0 and ((b - x) % 3 == 0):
		print('YES')
	else:
		print('NO')


def main():
	t = int(input())
	for __ in range(t):
		(a, b) = map(int, input().split())
		if a > b:
			(a, b) = (b, a)
		if (a + b) % 3 == 0 and 2 * a >= b:
			print('YES')
		else:
			print('NO')
main()


t = int(input())
for test in range(t):
	(a, b) = map(int, input().split())
	t = a
	a = max(a, b)
	b = min(t, b)
	if (a + b) % 3 == 0 and a <= 2 * b:
		print('YES')
		continue
	print('NO')


n = int(input())
for i in range(n):
	(a, b) = [int(x) for x in input().split()]
	if a > b:
		tmp = a
		a = b
		b = tmp
	if a == 0 and b == 0:
		print('YES')
	elif a == 0 or b > 2 * a:
		print('NO')
	elif (a + b) % 3 == 0:
		print('YES')
	else:
		print('NO')


import math

class Read:

	@staticmethod
	def string():
		return input()

	@staticmethod
	def int():
		return int(input())

	@staticmethod
	def list(sep=' '):
		return input().split(sep)

	@staticmethod
	def list_int(sep=' '):
		return list(map(int, input().split(sep)))

def solve():
	(a, b) = Read.list_int()
	if (a + b) % 3 == 0:
		if math.fabs(a - b) <= min(a, b):
			print('YES')
			return
	print('NO')
query_count = Read.int()
while query_count:
	query_count -= 1
	solve()


t = int(input())
ans = []
for _ in range(t):
	(a, b) = map(int, input().split())
	if a * 2 < b or b * 2 < a or (a + b) % 3 != 0:
		ans.append('NO')
	elif a and b:
		ans.append('YES')
	elif not a and (not b):
		ans.append('YES')
	else:
		ans.append('NO')
print('\n'.join(ans))


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	(a, b) = (min(a, b), max(a, b))
	(c, d) = (2 * a - b, 2 * b - a)
	if c >= 0 and c % 3 == 0 and (b >= c / 3):
		print('YES')
	elif d >= 0 and d % 3 == 0 and (a >= d / 3):
		print('YES')
	else:
		print('NO')


import math

def function(a, b):
	l = [a, b]
	a1 = min(l)
	b1 = max(l)
	if 2 * a1 >= b1 and (a1 + b1) % 3 == 0:
		return 'YES'
	return 'NO'
t = int(input())
for k in range(t):
	(a, b) = map(int, input().rstrip().split())
	print(function(a, b))


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	if a > b:
		(a, b) = (b, a)
	same = a - (b - a)
	if same % 3 == 0 and same >= 0:
		print('YES')
	else:
		print('NO')


t = int(input())
while t:
	(n, k) = map(int, input().split())
	x = abs(n - k)
	if (min(n, k) - x) % 3 == 0 and max(n, k) <= 2 * min(n, k):
		print('YES')
	else:
		print('NO')
	t -= 1


n = int(input())
for i in range(n):
	(a, b) = map(int, input().split())
	if (a + b) % 3 == 0 and min(a, b) * 2 >= max(a, b):
		print('YES')
	else:
		print('NO')


def solve(a, b):
	if (a + b) % 3 != 0:
		return False
	x_add_y = (a + b) // 3
	x_sub_y = a - b
	if (x_add_y + x_sub_y) % 2 != 0:
		return False
	x = (x_add_y + x_sub_y) // 2
	y = (x_add_y - x_sub_y) // 2
	if x < 0:
		return False
	if y < 0:
		return False
	return True

def main():
	cas = int(input())
	while cas > 0:
		cas -= 1
		(a, b) = map(int, input().split())
		ans = solve(a, b)
		if ans:
			print('YES')
		else:
			print('NO')
main()


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	m = (2 * a - b) / 3
	n = (2 * b - a) / 3
	if m == int(m) and m >= 0 and (n == int(n)) and (n >= 0):
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	b = (2 * x - y) / 3
	a = y - x + b
	if a >= 0 and b >= 0 and (a % 1 == 0) and (b % 1 == 0):
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	if (a + b) % 3 != 0 or a > 2 * b or b > 2 * a:
		print('NO')
	else:
		print('YES')


def run_testcase():
	[a, b] = [int(x) for x in input().split()]
	if (a + b) % 3 != 0:
		return 'NO'
	x_l = (2 * b - a) // 3
	x_u = b - 2 * x_l
	if x_l >= 0 and x_u >= 0:
		return 'YES'
	x_l = (2 * a - b) // 3
	x_u = a - 2 * x_l
	if x_l >= 0 and x_u >= 0:
		return 'YES'
	return 'NO'
testcase_count = int(input())
for i in range(testcase_count):
	print(str(run_testcase()))


import sys
import bisect as b
input = sys.stdin.readline
mo = 10 ** 9 + 7

def cin():
	return map(int, sin().split())

def ain():
	return list(map(int, sin().split()))

def sin():
	return input()

def inin():
	return int(input())
for i in range(inin()):
	(c, s) = cin()
	if c > s:
		(c, s) = (s, c)
	if (s + c) % 3 == 0 and 2 * c >= s:
		print('YES')
	else:
		print('NO')


from sys import stdin
for _ in [0] * int(input()):
	(a, k) = map(int, stdin.readline().rstrip().split(' '))
	(a, k) = (min(a, k), max(a, k))
	if (a + k) % 3 or 2 * a < k:
		print('NO')
	else:
		print('Yes')


n = int(input())
for i in range(n):
	s = input()
	ar = s.split(' ')
	n1 = min(int(ar[0]), int(ar[1]))
	n2 = max(int(ar[0]), int(ar[1]))
	if (n1 + n2) % 3 == 0 and n2 - 2 * n1 <= 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for rep in range(0, t):
	(a, b) = input().split()
	a = int(a)
	b = int(b)
	if (a + b) % 3 == 0 and a <= 2 * b and (b <= 2 * a):
		print('YES')
	else:
		print('NO')


T = int(input())
answer = ''
for t in range(T):
	text = list(map(int, input().split(' ')))
	text.sort()
	a = text[1]
	b = text[0]
	if a == b * 2:
		answer += 'YES\n'
		continue
	if b * 2 < a:
		answer += 'NO\n'
		continue
	if (2 * b - a) % 3 == 0:
		answer += 'YES\n'
	else:
		answer += 'NO\n'
print(answer)


T = int(input())
for t in range(T):
	(a, b) = map(int, input().split())
	if a > b:
		(a, b) = (b, a)
	diff = b - a
	a -= diff
	b -= 2 * diff
	if a >= 0 and a % 3 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
out = []
for i in range(t):
	ab = [int(c) for c in input().split()]
	if (ab[0] + ab[1]) % 3 != 0:
		out.append('NO')
	elif abs(ab[0] - ab[1]) > min(ab):
		out.append('NO')
	else:
		out.append('YES')
for i in range(t):
	print(out[i])


import sys
import math
from collections import defaultdict
from collections import deque
from itertools import combinations
from itertools import permutations
input = lambda : sys.stdin.readline().rstrip()
read = lambda : map(int, input().split())

def write(*args, sep='\n'):
	for i in args:
		sys.stdout.write('{}{}'.format(i, sep))
INF = float('inf')
MOD = int(1000000000.0 + 7)
for _ in range(int(input())):
	(x, y) = map(int, input().split())
	if y > x:
		(x, y) = (y, x)
	z = x - y
	if (x + y) % 3 != 0:
		print('NO')
		continue
	if z > min(x, y):
		print('NO')
		continue
	x -= 2 * z
	y -= z
	if x % 3 == 0:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	a = list(map(int, input().split()))
	a.sort()
	need = a[1] - a[0]
	while need > 1 and a[0] > 0 and (a[1] > 0):
		time = need // 2
		time = min(a[0], time)
		a[0] -= time
		a[1] -= time * 2
		a.sort()
		need = a[1] - a[0]
	if a[0] == a[1]:
		if a[0] % 3 == 0:
			print('YES')
		else:
			print('NO')
	elif abs(a[0] - a[1]) == 1:
		a[0] -= 1
		a[1] -= 2
		if a[0] == a[1]:
			if a[0] % 3 == 0:
				print('YES')
			else:
				print('NO')
	else:
		print('NO')


line = input()
for i in range(int(line)):
	l = input().split()
	a = int(l[0])
	b = int(l[1])
	if 2 * a < b or 2 * b < a:
		print('no')
	elif (a + b) % 3 == 0:
		print('yes')
	else:
		print('no')


n = int(input())
flag = 0
for _ in range(n):
	(a, b) = list(map(int, input().split()))
	if (a + b) % 3 or a > 2 * b or b > 2 * a:
		print('NO')
	else:
		print('YES')


t = int(input())
for i in range(t):
	(a, b) = list(map(int, input().split()))
	if a > b:
		temp = a
		a = b
		b = temp
	c = 2 * a - b
	if c >= 0 and c % 3 == 0:
		print('YES')
	else:
		print('NO')


import collections
for t in range(int(input())):
	(a, b) = list(map(int, input().split()))
	if (a + b) % 3 == 0 and 2 * min(a, b) >= max(a, b):
		print('YES')
	else:
		print('NO')


import math
n = int(input())
for i in range(n):
	(a, b) = list(map(int, input().split()))
	if a == 1 and b == 1:
		print('NO')
		continue
	if a > 2 * b or b > 2 * a:
		print('NO')
		continue
	while a != b:
		e = int(math.ceil(abs(a - b) / 2))
		if a < b:
			a -= e
			b -= 2 * e
		else:
			a -= 2 * e
			b -= e
	if a == 0 or a % 3 == 0:
		print('YES')
	else:
		print('NO')


import sys
input = sys.stdin.readline
t = int(input())
for testcases in range(t):
	(a, b) = list(map(int, input().split()))
	if a > 2 * b or b > 2 * a:
		print('NO')
	elif (a + b) % 3 == 0:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	ab = [int(x) for x in input().split(' ')]
	a = ab[0]
	b = ab[1]
	if a > b:
		tmp = a
		a = b
		b = tmp
	if b > a * 2:
		print('NO')
		continue
	if a == 0 and b == 0:
		print('YES')
		continue
	d = b - a
	a -= d
	b -= d * 2
	if a - 1 % 3 == 0 and b - 2 % 3 == 0 or (a % 3 == 0 and b % 3 == 0) or (a - 1 == 0 and b - 2 == 0):
		print('YES')
	else:
		print('NO')


n = int(input())
for x in range(n):
	(a, b) = map(int, input().split())
	if a >= 3 and b >= 3:
		if min(a, b) < abs(a - b):
			print('NO')
		else:
			a %= 3
			b %= 3
			if a == 0 and b == 0 or (a == 1 and b == 2) or (a == 2 and b == 1):
				print('YES')
			else:
				print('NO')
	elif min(a, b) < abs(a - b):
		print('NO')
	elif a == 1 and b == 2 or (a == 2 and b == 1) or (a == 0 and b == 0) or (abs(a - b) == min(a, b)):
		print('YES')
	else:
		print('NO')


N = int(input())
for _ in range(N):
	(a, b) = map(int, input().split())
	if (a + b) % 3 == 0 and a <= 2 * b and (b <= 2 * a):
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	(a, b) = map(int, input().split())
	if a > b:
		(a, b) = (b, a)
	print('yes') if (a + b) % 3 == 0 and a * 2 >= b else print('NO')


import sys
import math
get_string = lambda : sys.stdin.readline().strip()
get_list = lambda : list(map(int, sys.stdin.readline().strip().split()))
get_int = lambda : int(sys.stdin.readline())
for _ in range(get_int()):
	lst = get_list()
	(a, b) = (min(lst), max(lst))
	d = b - a
	if a >= d and b >= 2 * d:
		a -= d
		b -= 2 * d
		if a == b and a % 3 == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


n = int(input())
for i in range(n):
	(a, b) = map(int, input().split(' '))
	if (a + b) % 3 == 0:
		if b >= a:
			if a * 2 >= b:
				print('YES')
			else:
				print('NO')
		elif a >= b:
			if b * 2 >= a:
				print('YES')
			else:
				print('NO')
	else:
		print('NO')


import math
n = int(input())
Result = []
for i in range(0, n):
	List = list(map(int, input().strip().split()))[0:2]
	a = List[0]
	b = List[1]
	if a > b:
		h = a
		l = b
	elif b >= a:
		h = b
		l = a
	if 2 * l == h:
		Result.append('YES')
	elif (2 * h - l) % 3 == 0:
		x = int((2 * h - l) / 3)
		if 2 * (h - 2 * x) > 0 and l - x > 0:
			Result.append('YES')
		else:
			Result.append('NO')
	else:
		Result.append('NO')
for i in Result:
	print(i)


for nt in range(int(input())):
	(a, b) = map(int, input().split())
	if (a + b) % 3 != 0 or min(a, b) * 2 < max(a, b):
		print('NO')
		continue
	print('YES')


import math
n = int(input())
for _ in range(n):
	ans = 0
	(a, b) = map(int, input().split())
	c = a + b
	c = c % 3
	if c == 0 and min(a, b) + min(a, b) >= max(a, b):
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(x, y) = (max(x, y), min(x, y))
	if 2 * y == x:
		print('YES')
	elif y * 2 < x:
		print('NO')
	else:
		print('NO' if (x + y) % 3 else 'YES')


import sys

class IoTool:
	DEBUG = 0

	def _reader_dbg():
		with open('./input.txt', 'r') as f:
			lines = f.readlines()
		for l in lines:
			yield l.strip()

	def _reader_oj():
		return iter(sys.stdin.read().split('\n'))
	reader = _reader_dbg() if DEBUG else _reader_oj()

	def read():
		return next(IoTool.reader)
input = IoTool.read

def main():
	(a, b) = map(int, input().split())
	if (a + b) % 3 != 0:
		print('NO')
	elif min(a, b) * 2 < max(a, b):
		print('NO')
	else:
		print('YES')
n = int(input())
for _ in range(n):
	main()


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	(a, b) = (min(a, b), max(a, b))
	print('YES' if not (a + b) % 3 and a * 2 >= b else 'NO')


for i in range(int(input())):
	(s, b) = map(int, input().split())
	if s > b:
		(s, b) = (b, s)
	if (s + b) % 3 == 0 and s * 2 >= b:
		print('Yes')
	else:
		print('No')


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	ma = max(a, b)
	mn = min(a, b)
	if ma - mn <= mn and (mn + mn - ma) % 3 == 0:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	if (a + b) % 3 == 0 and max(a, b) <= min(a, b) * 2:
		print('yes')
	else:
		print('no')


import sys

def input():
	return sys.stdin.readline()

def mapi():
	return map(int, input().split())

def maps():
	return map(str, input().split())

def solve():
	t = 1
	t = int(input())
	while t:
		t -= 1
		(a, b) = mapi()
		ss = max(a, b)
		mm = min(a, b)
		if (mm + ss) % 3 == 0 and 2 * mm - ss >= 0:
			print('YES')
		else:
			print('NO')
solve()


for _ in range(int(input())):
	(a, b) = [int(s) for s in input().split()]
	if (a + b) % 3 != 0:
		print('NO')
	elif (a + b) // 3 > min(a, b):
		print('NO')
	else:
		print('YES')


t = int(input())
for _ in range(t):
	(a, b) = (int(i) for i in input().split())
	(a, b) = (min(a, b), max(a, b))
	if 2 * a - b >= 0 and (2 * a - b) % 3 == 0:
		print('YES')
	else:
		print('No')


t = int(input())
for i in range(t):
	(a, b) = list(map(int, input().strip().split()))
	if a > 2 * b or b > 2 * a or (a + b) % 3:
		print('NO')
	else:
		print('YES')


import io, sys, atexit, os
import math as ma
from sys import exit
from decimal import Decimal as dec
from itertools import permutations
from itertools import combinations

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

def num():
	return map(int, sys.stdin.readline().split())

def nu():
	return int(input())

def find_gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def lcm(x, y):
	gg = find_gcd(x, y)
	return x * y // gg
mm = 1000000007

def solve():
	t = nu()
	for tt in range(t):
		(a, b) = num()
		if a > b:
			(a, b) = (b, a)
		if a == 1 and b == 2:
			print('Yes')
			continue
		if a == 1 and b == 1:
			print('No')
			continue
		fp = min(a, b - a)
		a -= fp
		b -= 2 * fp
		if a == 0 and b == 0:
			print('YES')
		elif a % 3 == 0 and b % 3 == 0 and (a > 0) and (b > 0):
			print('YES')
		else:
			print('NO')
solve()


from sys import stdin

def rl():
	return [int(w) for w in stdin.readline().split()]

def xuli(a, b):
	if (a + b) % 3 != 0:
		return 0
	else:
		tmp = (a + b) // 3
		if tmp > min(a, b) or 2 * tmp < max(a, b):
			return 0
		else:
			t = min(a, b) - tmp
			if 2 * tmp - t == max(a, b):
				return 1
			else:
				return 0
test = int(stdin.readline())
while test:
	test -= 1
	(a, b) = rl()
	if a == 0 and b == 0:
		print('YES')
		continue
	elif a == 0 or b == 0:
		print('NO')
		continue
	res = int(0)
	res = max(res, xuli(a - 1, b - 2), xuli(a - 2, b - 1))
	if res == 1:
		print('YES')
	else:
		print('NO')


from math import gcd
t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	if (a + b) % 3 == 0 and max(a, b) // 2 <= min(a, b):
		print('YES')
	else:
		print('NO')


from sys import stdin, stdout
from bisect import bisect_right, bisect_left
from math import gcd
n = int(stdin.readline())
for i in range(n):
	(a, b) = map(int, stdin.readline().split())
	if (a + b) % 3 != 0:
		stdout.write('NO' + '\n')
		continue
	tot = (a + b) // 3
	if a < tot or b < tot:
		stdout.write('NO' + '\n')
		continue
	stdout.write('YES' + '\n')


t = int(input())
while t > 0:
	t -= 1
	(a, b) = map(int, input().split())
	if a > b:
		temp = a
		a = b
		b = temp
	if b <= 2 * a:
		b = 2 * a - b
		if b % 3 == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


t = int(input())
for w in range(t):
	(a, b) = (int(i) for i in input().split())
	k1 = min(a, b)
	k2 = max(a, b)
	if k1 * 2 >= k2 and (a + b) % 3 == 0:
		print('YES')
	else:
		print('NO')


n = int(input())
for _ in range(n):
	(a, b) = map(int, input().split())
	if a < b:
		min = a
		max = b
	else:
		min = b
		max = a
	if min * 2 == max:
		print('YES')
	elif min * 2 < max:
		print('NO')
	else:
		k = 2 * min - max
		if k % 3 == 0:
			print('YES')
		else:
			print('NO')


for _ in [0] * int(input()):
	(a, b) = map(int, input().split())
	print('NYOE S'[(a + b) % 3 < 1 and a <= 2 * b <= 4 * a::2])


t = int(input())
for __ in range(t):
	(a, b) = map(int, input().split())
	if a > b:
		(a, b) = (b, a)
	diff = b - a
	a -= diff
	if a < 0 or a % 3:
		print('NO')
	else:
		print('YES')


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	u3 = 2 * b - a
	v3 = 2 * a - b
	if u3 >= 0 and v3 >= 0 and (u3 % 3 == 0) and (v3 % 3 == 0):
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	if max(n, m) > 2 * min(n, m):
		print('NO')
	elif (2 * min(n, m) - max(n, m)) % 3 == 0:
		print('YES')
	else:
		print('NO')


a = int(input())
for i in range(0, a):
	n = []
	(A, B) = list(map(int, input().split()))
	n.append(A)
	n.append(B)
	n.sort()
	x = n[0]
	y = n[1]
	if (x + y) % 3 == 0 and y <= 2 * x:
		print('YES')
	else:
		print('NO')


n = int(input())
i = 1
while i <= n:
	(a, b) = map(int, input().split())
	if a * 2 < b or b * 2 < a:
		print('NO')
	else:
		c = a + b
		if c % 3 == 0:
			print('YES')
		else:
			print('NO')
	i = i + 1


def main():
	t = int(input())
	for i in range(t):
		solve()

def solve():
	(a, b) = list(map(int, input().split(' ')))
	min_val = min(a, b)
	max_val = max(a, b)
	if (a + b) % 3 == 0 and min_val * 2 >= max_val:
		print('YES')
		return
	print('NO')
main()


from math import ceil
for _ in range(int(input())):
	(a, b) = list(map(int, input().split()))
	(a, b) = (min(a, b), max(a, b))
	if ceil(a / 2) <= b <= a * 2:
		if abs(2 * a - b) % 3 == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


from sys import stdin as s
for i in range(int(s.readline())):
	(a, b) = map(int, input().split())
	(n, m) = ((2 * a - b) / 3, (2 * b - a) / 3)
	if n >= 0 and n == int(n) and (m >= 0) and (m == int(m)):
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	a = list(map(int, input().split()))
	a.sort()
	if (a[0] + a[1]) % 3 == 0 and a[0] * 2 >= a[1]:
		print('YES')
	else:
		print('NO')


import os
import sys

def main():
	T = read_int()
	for _ in range(T):
		print('YES' if solve(*read_ints()) else 'NO')

def solve(A, B):
	p = -A + 2 * B
	q = 2 * A - B
	return p >= 0 and q >= 0 and (p % 3 == 0) and (q % 3 == 0)
DEBUG = 'DEBUG' in os.environ

def inp():
	return sys.stdin.readline().rstrip()

def read_int():
	return int(inp())

def read_ints():
	return [int(e) for e in inp().split()]

def dprint(*value, sep=' ', end='\n'):
	if DEBUG:
		print(*value, sep=sep, end=end)
main()


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
testcases = int(input())
for j in range(testcases):
	(a, b) = map(int, input().split())
	diff = abs(a - b)
	maxy = max(a, b)
	minny = min(a, b)
	if 2 * minny >= maxy:
		if (maxy + minny) % 3 == 0:
			print('YES')
		else:
			print('NO')
	elif minny == 1:
		if maxy == 2:
			print('YES')
		else:
			print('NO')
	elif maxy == 0:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(x1, x2) = list((int(i) for i in input().split()))
	u = x1 - x2
	a = (x1 - 2 * u) // 3
	if x1 == 0 and x2 == 0:
		print('YES')
		continue
	if (x1 - 2 * u) % 3 == 0:
		b = (x1 - a) // 2
		if a <= x1 and a >= 0:
			if x2 == b + 2 * a:
				print('YES')
				continue
		print('NO')
	else:
		print('NO')


import math
import os
import sys
input = lambda : sys.stdin.readline().strip('\r\n')

def cin():
	return sys.stdin.readline().strip('\r\n')

def fora():
	return list(map(int, sys.stdin.readline().strip().split()))

def string():
	return sys.stdin.readline().strip()

def cout(ans):
	sys.stdout.write(str(ans))

def endl():
	sys.stdout.write(str('\n'))

def ende():
	sys.stdout.write(str(' '))

def main():
	for _ in range(int(input())):
		(a, b) = map(int, cin().split())
		if a == 0 and b == 0:
			cout('YES')
		elif a == 0 or b == 0:
			cout('NO')
		elif (a + b) % 3 == 0 and max(a, b) <= 2 * min(a, b):
			cout('YES')
		else:
			cout('NO')
		endl()
main()


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	(a, b) = (min(a, b), max(a, b))
	if a * 2 < b:
		print('NO')
		continue
	c = b - a
	a -= c
	b -= c * 2
	if not a and (not b):
		print('YES')
		continue
	if not a or not b:
		print('NO')
		continue
	a = a % 3
	b = b % 3
	if not a and (not b):
		print('YES')
		continue
	if not a or not b:
		print('NO')
		continue
	if a == b:
		print('NO')
	else:
		print('YES')


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	if a < b:
		(a, b) = (b, a)
	if b == 0 and a != 0:
		print('No')
	else:
		a -= 2 * (a - b)
		b -= a - b
		if a < 0 or a % 3 != 0:
			print('No')
		else:
			print('Yes')


from sys import stdin
input = lambda : stdin.readline().rstrip('\r\n')
input_a = lambda fun: map(fun, stdin.readline().split())

def read():
	(a, b) = input_a(int)
	return (a, b)

def solve(a, b):
	(a, b) = sorted([a, b], reverse=True)
	return (a + b) % 3 == 0 and a <= b * 2
for t in range(int(input())):
	result = solve(*read())
	print('YES' if result else 'NO')


import os
import sys
from math import *
from collections import *
from bisect import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
ALPHA = 'abcdefghijklmnopqrstuvwxyz'
M = 10 ** 9 + 7
EPS = 1e-06

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
for _ in range(Int()):
	(a, b) = sorted(value())
	if 2 * a >= b and (a + b) % 3 == 0:
		ans = 'YES'
	else:
		ans = 'NO'
	print(ans)


n = int(input())
for i in range(n):
	(a, b) = [int(x) for x in input().split(' ')]
	if (a + b) % 3 != 0:
		print('NO')
	elif max(a, b) > 2 * min(a, b):
		print('NO')
	elif (2 * min(a, b) - max(a, b)) % 3 == 0:
		print('YES')
	else:
		print('NO')


from sys import stdin
with stdin as fin:
	q = int(fin.readline().rstrip())
	for i in range(q):
		[a, b] = [int(i) for i in fin.readline().rstrip().split()]
		if a > b:
			c = a
			a = b
			b = c
		if (a + b) % 3 == 0 and 2 * a >= b:
			print('YES')
		else:
			print('NO')


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	if a == 0 or b == 0:
		if a == 0 and b == 0:
			print('Yes')
		else:
			print('No')
	elif a == b:
		if a % 3 == 0:
			print('Yes')
		else:
			print('No')
	elif (a + b) % 3 == 0:
		if max(a, b) <= 2 * min(a, b):
			print('Yes')
		else:
			print('No')
	else:
		print('No')


t = int(input())
for case in range(t):
	(c, d) = [int(zax) for zax in input().split()]
	a = min(c, d)
	b = max(c, d)
	if 2 * a - b >= 0 and 2 * b - a >= 0 and ((2 * b - a) % 3 == 0) and ((2 * a - b) % 3 == 0):
		print('YES')
	else:
		print('NO')


from collections import deque
from math import ceil, sqrt

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().split())

def li():
	return list(mi())
abc = 'abcdefghijklmnopqrstuvwxyz'
t = ii()
while t:
	t -= 1
	(a, b) = mi()
	if max(a, b) - min(a, b) <= min(a, b):
		if (a + b) % 3 == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


def f():
	(a, b) = [int(s) for s in input().split()]
	c = 2 * a - b
	d = 2 * b - a
	if c < 0 or d < 0 or c % 3 != 0 or (d % 3 != 0):
		print('NO')
	else:
		print('YES')
n = int(input())
for i in range(n):
	f()


for _ in range(int(input())):
	(a, b) = [int(__) for __ in input().split()]
	if a == 0 and b == 0:
		print('YES')
		continue
	if a * b == 0:
		print('NO')
		continue
	if (a + b) % 3 == 0 and 2 * min(a, b) >= max(a, b):
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	(a, b) = [int(j) for j in input().split()]
	if (a + b) % 3 != 0 or abs(a - b) > min(a, b):
		print('NO')
	else:
		print('YES')


def main():
	import sys
	input = sys.stdin.readline
	N = int(input())
	for _ in range(N):
		(a, b) = map(int, input().split())
		ok = 1
		x1 = 2 * b - a
		x2 = 2 * a - b
		if x1 % 3 != 0 or x1 < 0:
			ok = 0
		if x2 % 3 != 0 or x2 < 0:
			ok = 0
		if ok:
			print('YES')
		else:
			print('NO')
main()


import math
x = eval(input())
for i in range(x):
	y = input().split(' ')
	a = min(int(y[0]), int(y[1]))
	b = max(int(y[0]), int(y[1]))
	if b <= 2 * a and (a + b) % 3 == 0:
		print('YES')
	else:
		print('NO')


import math
t = int(input())
while t > 0:
	t -= 1
	(a, b) = map(int, input().split())
	if a > b:
		(a, b) = (b, a)
	if (a + b) % 3 == 0 and 2 * a >= b:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	if (x + y) % 3 == 0 and abs(x - y) <= max(x, y) // 2:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	t = sorted([int(j) for j in input().split()])
	print('YNEOS'[sum(t) % 3 > 0 or t[0] * 2 < t[1]::2])


from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations
import sys
import bisect
import string
import math
import time

def I():
	return int(input())

def MI():
	return map(int, input().split())

def LI():
	return [int(i) for i in input().split()]

def LI_():
	return [int(i) - 1 for i in input().split()]

def StoI():
	return [ord(i) - 97 for i in input()]

def ItoS(nn):
	return chr(nn + 97)

def show(*inp, end='\n'):
	if show_flg:
		print(*inp, end=end)
YN = ['Yes', 'No']
mo = 10 ** 9 + 7
inf = float('inf')
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
input = lambda : sys.stdin.readline().rstrip()
show_flg = False
show_flg = True
t = I()
for _ in range(t):
	ans = 0
	(a, b) = LI()
	(X, Y) = (2 * b - a, 2 * a - b)
	if X >= 0 and X % 3 == 0 and (Y >= 0) and (Y % 3 == 0):
		k = 0
	else:
		k = 1
	print(YN[k])


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	k1 = (2 * b - a) / 3
	k2 = (2 * a - b) / 3
	if k1 == int(k1) and k2 == int(k2) and (k1 >= 0) and (k2 >= 0):
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(a, b) = map(int, input().split(' '))
	mx = max(a, b)
	mn = min(a, b)
	if (mx + mn) % 3 == 0 and mx <= 2 * mn:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	(a, b) = map(int, input().split())
	if a == 0 and b == 0:
		print('YES')
	elif a == 0 or b == 0:
		print('NO')
	elif a == 1 and b == 1:
		print('NO')
	elif a == 2 and b == 2:
		print('NO')
	elif (a + b) % 3 == 0 and 2 * min(a, b) >= max(a, b):
		print('YES')
	else:
		print('NO')


t = int(input())
for testcase in range(t):
	(a, b) = [int(ele) for ele in input().split()]
	s = min(a, b)
	l = max(a, b)
	if ((2 * a - b) % 3 == 0 or (2 * b - a) % 3 == 0) and a <= 2 * b and (b <= 2 * a):
		print('YES')
	else:
		print('NO')


def answer():
	(a, b) = map(int, input().split(' '))
	val1 = -a + 2 * b
	val2 = 2 * a - b
	cond1 = val1 % 3 == 0 and val1 >= 0
	cond2 = val2 % 3 == 0 and val2 >= 0
	if cond1 and cond2:
		return 'YES'
	else:
		return 'NO'
n = int(input())
for _ in range(n):
	print(answer())


n = input()
n = int(n)
for _ in range(n):
	(a, b) = map(int, input().split())
	if a > b:
		(a, b) = (b, a)
	if a * 2 < b:
		print('no')
	else:
		dif = b - a
		a -= dif
		if a % 3 == 0:
			print('yes')
		else:
			print('no')


cases = int(input())
for case in range(cases):
	(a, b) = list(map(int, input().split()))
	if a > b:
		(a, b) = (b, a)
	if b > a * 2:
		print('NO')
	elif (a + b) % 3 == 0:
		print('YES')
	else:
		print('NO')


from sys import stdin, stdout

def memoize(f):
	memo = {}

	def helper(*x):
		if x not in memo:
			memo[x] = f(*x)
		return memo[x]
	return helper

@memoize
def brute(x, y):
	if x == 0 and y == 0:
		return True
	if x <= 0 or y <= 0:
		return False
	return brute(x - 1, y - 2) or brute(x - 2, y - 1)

def ans(x, y):
	if x == 0 and y == 0:
		return True
	if x == 0 or y == 0:
		return False
	diff = abs(x - y)
	s = x + y
	if s % 3 != 0:
		return False
	steps = s / 3
	if diff % 2 != steps % 2:
		return False
	if diff > steps:
		return False
	return True

def main():
	data = stdin.read().split('\n')
	N = int(data[0])
	for row in data[1:N + 1]:
		(x, y) = map(int, row.split(' '))
		if ans(x, y):
			stdout.write('YES\n')
		else:
			stdout.write('NO\n')
main()


for _ in ' ' * int(input()):
	(a, b) = map(int, input().split())
	if a < b:
		(a, b) = (b, a)
	if a > 2 * b:
		print('NO')
	else:
		print('YNEOS'[(a + b) % 3 != 0::2])


t = int(input())
while t > 0:
	t = t - 1
	w = input()
	w = w.split()
	x = int(w[0])
	y = int(w[1])
	if x > y:
		(x, y) = (y, x)
	if (x + y) % 3 == 0 and y <= 2 * x:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	if a > b:
		(a, b) = (b, a)
	temp = a + b
	if temp % 3 == 0:
		if b - a > a:
			print('NO')
		else:
			print('YES')
	else:
		print('NO')


def check(a, b):
	if (2 * a - b) / 3 < 0 or (2 * a - b) % 3 != 0:
		return False
	A = (2 * a - b) / 3
	if (b - A) / 2 < 0 or (b - A) % 2 != 0:
		return False
	return True
T = int(input())
for t in range(T):
	(a, b) = [int(i) for i in input().split()]
	if check(a, b):
		print('YES')
	else:
		print('NO')


x = int(input())
for i in range(x):
	(q, w) = map(int, input().split())
	if (q + w) % 3 == 0 and q * 2 >= w and (w * 2 >= q):
		print('YES')
	else:
		print('NO')


from math import *
from copy import *
from string import *
from random import *
from sys import stdin
from sys import maxsize
from operator import *
from itertools import *
from collections import Counter
import math

def bin1(l, r, k, t, b, val, ans):
	if l > r:
		return ans
	else:
		mid = (l + r) // 2
		v = k ** mid
		if v == val:
			return v
		elif v > val:
			ans = mid
			return bin1(mid + 1, r, k, t, b, val, ans)
		else:
			return bin1(l, mid - 1, k, t, b, val, ans)

def bin2(l, r, k, t, b, val, ans):
	if l > r:
		return ans
	else:
		mid = (l + r) // 2
		v = t * k ** mid + b * mid
		if v == val:
			return v
		elif v > val:
			ans = mid
			return bin2(l, mid - 1, k, t, b, val, ans)
		else:
			return bin2(mid + 1, r, k, t, b, val, ans)

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	l = []
	for i in range(2, n + 1):
		if prime[i]:
			l.append(i)
	return l

def bin(l, r, ll, val):
	if l > r:
		return -1
	else:
		mid = (l + r) // 2
		if val >= ll[mid][0] and val <= ll[mid][1]:
			return mid
		elif val < ll[mid][0]:
			return bin(l, mid - 1, ll, val)
		else:
			return bin(mid + 1, r, ll, val)

def deci(n):
	s = ''
	while n != 0:
		if n % 2 == 0:
			n = n // 2
			s = '0' + s
		else:
			n = n // 2
			s = '1' + s
	return s

def diff(s1, s2):
	if len(s1) < len(s2):
		v = len(s1)
		while v != len(s2):
			s1 = '0' + s1
			v = v + 1
	else:
		v = len(s2)
		while v != len(s1):
			s2 = '0' + s2
			v = v + 1
	c = 0
	for i in range(len(s1)):
		if s1[i:i + 1] != s2[i:i + 1]:
			c = c + 1
	return c
from sys import stdin, stdout

def fac(a, b):
	v = a
	while a != b:
		v *= a - 1
		a = a - 1
	return v

def bino(l, r, n):
	if l > r:
		return -1
	else:
		mid = (l + r) // 2
		val1 = math.log(n / mid + 1, 2)
		val2 = int(val1)
		if val1 == val2:
			return val1
		elif val1 < 1.0:
			return bino(l, mid - 1, n)
		else:
			return bino(mid + 1, r, n)

def binary(l, r, ll, val, ans):
	if l > r:
		return ans
	else:
		mid = (l + r) // 2
		if val % ll[mid] == 0:
			ans = ll[mid]
			return binary(l, mid - 1, ll, val, ans)
		else:
			return binary(l, mid - 1, ll, val, ans)

def odd(n, ans, s):
	if n % 2 != 0 or n in s:
		return ans
	else:
		s.add(n)
		return odd(n // 2, ans + 1, s)
t = int(input())
for i in range(t):
	(n, m) = map(int, input().split(' '))
	if (n + m) % 3 == 0 and max(n, m) <= min(n, m) * 2:
		print('YES')
	else:
		print('NO')


n = int(input())
for _ in range(n):
	(a, b) = [int(i) for i in input().split()]
	diff = abs(a - b)
	if a > b:
		a -= 2 * diff
		b -= diff
	elif a < b:
		a -= diff
		b -= 2 * diff
	if a >= 0 and a % 3 == 0:
		print('Yes')
	else:
		print('No')


def main():
	t = int(input())
	result = []
	for i in range(t):
		(a, b) = map(int, input().split())
		if (a + b) % 3 == 0 and min(a, b) >= (a + b) // 3:
			result.append('YES')
		else:
			result.append('no')
	for i in range(t):
		print(result[i])
main()


T = int(input())
for _ in range(0, T):
	(a, b) = map(int, input().split())
	t1 = 2 * a - b
	t2 = 2 * b - a
	if t2 % 3 == 0 and t1 % 3 == 0 and (t1 >= 0) and (t2 >= 0):
		print('YES')
	else:
		print('NO')


import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log2, ceil
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
from bisect import insort
from collections import Counter
from collections import deque
from heapq import heappush, heappop, heapify
from itertools import permutations, combinations
mod = int(1000000000.0) + 7
ip = lambda : int(stdin.readline())
inp = lambda : map(int, stdin.readline().split())
ips = lambda : stdin.readline().rstrip()
out = lambda x: stdout.write(str(x) + '\n')
t = ip()
for _ in range(t):
	(a, b) = inp()
	if a > b:
		(a, b) = (b, a)
	if a * 2 < b:
		ans = 'NO'
	elif a == 2 * b:
		ans = 'YES'
	elif (2 * a - b) % 3 == 0:
		ans = 'YES'
	else:
		ans = 'NO'
	out(ans)


import math
t = int(input())
for i in range(t):
	(a, b) = map(int, input().split(' '))
	if min(a, b) * 2 == max(a, b):
		print('yes')
	elif min(a, b) == 0:
		print('no')
	elif (a + b) % 3 == 0 and max(a, b) / min(a, b) <= 2.0:
		print('yes')
	else:
		print('no')


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	if (a + b) % 3 == 0 and abs(a - b) <= min(a, b):
		print('YES')
	else:
		print('NO')


from math import *
from collections import *
import sys
sys.setrecursionlimit(10 ** 9)
n = int(input())
for y in range(n):
	(x, y) = map(int, input().split())
	if x == 0 and y == 0:
		print('Yes')
	elif x * 2 < y or y * 2 < x:
		print('No')
	elif (x + y) % 3 == 0:
		print('Yes')
	else:
		print('No')


import os
import sys
from io import BytesIO, IOBase
from collections import Counter
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

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

def lcm(a, b):
	return a * b / gcd(a, b)

def main():
	n = int(input())
	for i in range(n):
		(a, b) = map(int, input().split())
		if a > b:
			(b, a) = (a, b)
		if b == 2 and a == 1:
			print('YES')
		elif a >= b - a and (a - (b - a)) % 3 == 0:
			print('YES')
		else:
			print('NO')
	return
main()


test_cases = int(input())
for i in range(test_cases):
	(a, b) = map(int, input().split())
	if (a + b) % 3 == 0 and abs(a - b) <= (a + b) / 3:
		print('yes')
	else:
		print('no')


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	ans = 'NO'
	if (a + b) % 3 == 0 and min(a, b) >= max(a, b) // 2 or a == b == 0:
		ans = 'YES'
	print(ans)


n = int(input())
lst = []
for i in range(n):
	lst1 = list(map(int, input().split()))
	lst.append(lst1)
for i in range(n):
	a = lst[i][0]
	b = lst[i][1]
	if a > b:
		(a, b) = (b, a)
	if b == 2 * a:
		print('yes')
	else:
		c = b - a
		if (a - c) % 3 == 0 and a - c >= 0:
			print('yes')
		else:
			print('no')


for _ in range(int(input())):
	l = list(map(int, input().split()))
	l = sorted(l)
	if l[1] > l[0] * 2:
		print('NO')
	else:
		l[1] -= l[0] * 2 + 3
		if l[1] % 3 == 0:
			print('YES')
		else:
			print('NO')


from copy import deepcopy
t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	(a, b) = (max(a, b), min(a, b))
	x = a - b
	if a - 2 * x < 0:
		print('NO')
		continue
	if (b - x) % 3 != 0:
		print('NO')
	else:
		print('YES')


n = int(input())
for _ in range(n):
	(a, b) = map(int, input().split())
	d = abs(a - b)
	val = min(a, b)
	if d > val:
		print('NO')
	elif (a + b) % 3:
		print('NO')
	else:
		print('YES')


t = int(input())
while t:
	(a, b) = [int(x) for x in input().split()]
	if 2 * b - a >= 0 and (2 * b - a) % 3 == 0 and (2 * a - b >= 0) and ((2 * a - b) % 3 == 0):
		print('YES')
	else:
		print('NO')
	t -= 1


n = int(input())
S = []
for _ in range(n):
	temp = list(map(int, input().split()))
	S.append(temp)
for i in range(n):
	a = S[i][0]
	b = S[i][1]
	if a == 0 and b == 0:
		print('YES')
	elif a == 0 or b == 0:
		print('NO')
	elif (a - 2 * b) % 3 == 0 and (b - 2 * a) % 3 == 0 and (2 * a - b >= 0) and (2 * b - a >= 0):
		print('YES')
	else:
		print('NO')


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from itertools import *
import bisect
from heapq import *
from math import *
from copy import *
from collections import deque
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func
mod = 1000000007

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def lcm(a, b):
	return a * b // gcd(a, b)

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def solve():
	(a, b) = sep()
	(a, b) = (min(a, b), max(a, b))
	diff = min(b - a, a)
	a -= diff
	b -= 2 * diff
	b -= a // 3 * 3
	a = a % 3
	if a == 1 and b == 2:
		print('YES')
		return
	if a == 0 and b == 0:
		print('YES')
		return
	print('NO')
testcase(int(inp()))


t = int(input())
for _ in range(t):
	(a, b) = (int(x) for x in input().split(' '))
	if a == 0 and b == 0:
		print('YES')
	elif a == 0 or b == 0:
		print('NO')
	elif max(a, b) / min(a, b) <= 2 and (a + b) % 3 == 0:
		print('YES')
	else:
		print('NO')


import sys
t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	if b > a:
		dif = b - a
		b = b - 2 * dif
		a = a - dif
	elif a > b:
		dif = a - b
		a = a - 2 * dif
		b = b - dif
	if a >= 0 and b >= 0 and (a % 3 == 0) and (b % 3 == 0):
		print('yes')
	else:
		print('no')


t = int(input())
for you in range(t):
	l = input().split()
	a = int(l[0])
	b = int(l[1])
	maxa = max(a, b)
	mina = min(a, b)
	if maxa <= 2 * mina and (a + b) % 3 == 0:
		print('YES')
	else:
		print('NO')


n = int(input())
while n:
	n -= 1
	(a, b) = map(int, input().split())
	if a > b:
		(a, b) = (b, a)
	if (a + b) % 3 == 0 and 2 * a >= b:
		print('YES')
	else:
		print('NO')


for itr in range(int(input())):
	(x, y) = map(int, input().split())
	if 2 * min(x, y) < max(x, y):
		print('NO')
		continue
	x = x % 3
	y = y % 3
	(x, y) = (min(x, y), max(x, y))
	if x == 0 and y == 0:
		print('YES')
	elif x == 1 and y == 2:
		print('YES')
	else:
		print('NO')


n = int(input())
for _ in range(n):
	(a, b) = map(int, input().split())
	ma = max(a, b)
	mi = min(a, b)
	if mi >= ma / 2 and (a + b) % 3 == 0:
		print('YES')
	else:
		print('NO')


for case in range(int(input())):
	(x, y) = [int(x) for x in input().split()]
	b = (2 * x - y) // 3
	a = x - 2 * b
	if (2 * x - y) % 3 == 0 and b >= 0 and (a >= 0):
		print('YES')
		continue
	(x, y) = (y, x)
	b = (2 * x - y) // 3
	a = x - 2 * b
	if (2 * x - y) % 3 == 0 and b >= 0 and (a >= 0):
		print('YES')
		continue
	print('NO')


cases = int(input())
tests = []
results = []
for i in range(cases):
	tests.append([int(item) for item in input().split()])
for test in tests:
	if sum(test) % 3 != 0:
		results.append('NO')
	else:
		total = sum(test) // 3
		op1 = test[0] - total
		op2 = test[1] - total
		if op1 >= 0:
			if op2 >= 0:
				results.append('YES')
			else:
				results.append('NO')
		else:
			results.append('NO')
for result in results:
	print(result)


for u in range(int(input())):
	(x, y) = map(int, input().split())
	(m, k) = (x * 2 - y, 2 * y - x)
	if m % 3 == 0 and k % 3 == 0 and (m >= 0) and (k >= 0):
		print('YES')
	else:
		print('NO')


from collections import defaultdict, Counter
from math import sqrt, log10, log2, log, gcd, floor, factorial
from bisect import bisect_left, bisect_right
from itertools import combinations, combinations_with_replacement
import sys, io, os
input = sys.stdin.readline
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
mod = 10 ** 9 + 7
inf = float('inf')

def get_list():
	return [int(i) for i in input().split()]
yn = lambda a: print('YES' if a else 'NO')
ceil = lambda a, b: (a + b - 1) // b
t = int(input())
for i in range(t):
	(x, y) = get_list()
	suma = (x + y) // 3
	diff = abs(x - y)
	first = (suma + diff) // 2
	second = (suma - diff) // 2
	if (x + y) % 3 != 0 or (diff + suma) % 2 != 0 or first < 0 or (second < 0):
		yn(0)
	else:
		yn(1)


t = int(input())
for _ in range(t):
	(a, b) = [int(p) for p in input().split()]
	if (a + b) % 3 == 0 and min(a, b) * 2 >= max(a, b):
		print('YES')
	else:
		print('NO')


import math
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	if a > b:
		if a <= 2 * b and (a + b) % 3 == 0:
			print('YES')
		else:
			print('NO')
	elif b <= 2 * a and (a + b) % 3 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	(x, y) = (min(a, b), max(a, b))
	if 2 * x - y >= 0 and (2 * x - y) % 3 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	(a, b) = sorted([a, b])
	if a == 1 and b == 1:
		print('NO')
		continue
	d = b - a
	if d > a:
		print('NO')
		continue
	y = (2 * b - a) / 3
	if y % 1 != 0:
		print('NO')
		continue
	x = (a - y) / 2
	if x % 1 == 0 and y >= 0:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	kk = list(map(int, input().split()))
	a = max(kk)
	b = min(kk)
	l = 0
	r = max(a, b)
	while True:
		mid = (l + r) // 2
		if a - 2 * mid == 2 * (b - mid) or 2 * (a - 2 * mid) == b - mid:
			print('YES')
			break
		elif a - 2 * mid > 2 * (b - mid) or 2 * (a - 2 * mid) < b - mid:
			r = mid
		else:
			l = mid
		if l == r or l == r - 1:
			print('NO')
			break


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	if b > a:
		(a, b) = (b, a)
	s = a + b
	f = True
	if s % 3 != 0:
		f = False
	if a > 2 * b:
		f = False
	if f:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	print(['NO', 'YES'][(a + b) % 3 == 0 and a <= 2 * b and (b <= 2 * a)])


import sys, math

def input():
	return sys.stdin.readline()[:-1]

def main():
	Q = int(input())
	for _ in range(Q):
		(a, b) = map(int, input().split())
		if a == 0 and b == 0:
			print('YES')
		elif a == 0 and b != 0:
			print('NO')
		elif a != 0 and b == 0:
			print('NO')
		elif (a + b) % 3 == 0:
			if min(a, b) >= abs(a - b):
				print('YES')
			else:
				print('NO')
		else:
			print('NO')
main()


for i in range(int(input())):
	(a, b) = map(int, input().split())
	mi = min(a, b)
	ma = max(a, b)
	r = 2 * mi - ma
	if r % 3 == 0 and r >= 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(a, b) = [int(x) for x in input().split()]
	if a % 2 == 0:
		if a / 2 <= b <= 2 * a and (a + b) % 3 == 0:
			print('YES')
		else:
			print('NO')
	elif int(a / 2) + 2 <= b <= a * 2 and (a + b) % 3 == 0:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(a, b) = list(map(int, input().split()))
	m1 = min(a, b)
	m2 = max(a, b)
	if (a + b) % 3 == 0 and m2 <= 2 * m1:
		print('YES')
	else:
		print('NO')


import math
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	maxi = max(a, b)
	mini = min(a, b)
	if maxi <= mini * 2 and (mini + maxi) % 3 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	mini = min(a, b)
	minic = mini
	maxi = max(a, b)
	dif = maxi - mini
	div = (mini - dif) // 3
	mini = mini - div * 3
	maxi = maxi - div * 3
	if minic < dif:
		print('NO')
	elif dif == 0:
		if a % 3 == 0:
			print('YES')
		else:
			print('NO')
	elif maxi // mini == 2:
		print('YES')
	else:
		print('NO')


a = int(input())
for i in range(a):
	(x, y) = map(int, input().split())
	(x, y) = (min(x, y), max(x, y))
	if 2 * x < y:
		print('NO')
	elif 2 * x == y:
		print('YES')
	elif 2 * x - y > 0 and (2 * x - y) % 3 == 0:
		print('YES')
	else:
		print('NO')


def main():
	for _ in range(int(input())):
		(a, b) = list(map(int, input().split()))
		if (2 * b - a) % 3 == 0 and (2 * a - b) % 3 == 0:
			if (2 * b - a) // 3 >= 0 and (2 * a - b) // 3 >= 0:
				print('YES')
			else:
				print('NO')
		else:
			print('NO')
main()


def rint():
	return int(input())

def rints():
	return list(map(int, input().split()))
n = rint()
for _ in range(n):
	(a, b) = rints()
	if a < b:
		(a, b) = (b, a)
	d = a - b
	a -= 2 * d
	b -= d
	print('YES' if a >= 0 and a % 3 == 0 else 'NO')


t = int(input())
for i in range(t):
	f = 0
	(a, b) = map(int, input().split())
	if a == b:
		if a % 3 == 0:
			f = 1
	elif a > b:
		w = a - b
		if w <= b:
			a -= 2 * w
			b -= w
			if a % 3 == 0:
				f = 1
	elif b > a:
		w = b - a
		if w <= a:
			a -= w
			b -= 2 * w
			if a % 3 == 0:
				f = 1
	if f == 1:
		print('YES')
	else:
		print('NO')


t = int(input())
for nt in range(t):
	(a, b) = map(int, input().split())
	(a, b) = (max(a, b), min(a, b))
	diff = a - b
	b = b - diff
	if b >= 0 and b % 3 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
while t:
	t -= 1
	(a, b) = tuple(map(int, input().split()))
	if a > b:
		(a, b) = (b, a)
	if (2 * a - b) % 3 == 0 and b <= 2 * a:
		print('Yes')
	else:
		print('No')


for i in range(int(input())):
	(a, b) = map(int, input().split())
	max1 = max(a, b)
	min1 = min(a, b)
	if max1 > 2 * min1 or (max1 + min1) % 3 != 0:
		print('NO')
	else:
		print('YES')


t = int(input())
while t:
	t -= 1
	(a, b) = map(int, input().split())
	if a > b:
		(a, b) = (b, a)
	if b > a * 2 or (a + b) % 3:
		print('No')
		continue
	print('Yes')


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	mini = min(n, k)
	maxa = max(n, k)
	if mini == 1:
		if maxa == 2:
			print('Yes')
		else:
			print('No')
	else:
		dif = maxa - mini
		if mini - dif >= 0 and (mini - dif) % 3 == 0:
			print('Yes')
		else:
			print('No')


t = int(input())
arr = []
for _ in range(t):
	arr.append(list(map(int, input().strip().split())))
for n in range(t):
	if max(arr[n]) <= 2 * min(arr[n]) and sum(arr[n]) % 3 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for testcase in range(t):
	A = [int(x) for x in input().split()]
	(a, b) = (A[0], A[1])
	if (2 * b - a) % 3 == 0 and 2 * b >= a and (2 * a >= b):
		print('YES')
	else:
		print('NO')


def solve():
	(a, b) = map(int, input().split())
	(a, b) = sorted([a, b])
	f = False
	if b - a <= a:
		a = 2 * a - b
		if a % 3 == 0:
			f = True
	if f:
		print('YES')
	else:
		print('NO')
t = int(input())
for i in range(t):
	solve()


n = int(input())
for i in range(n):
	c = list(map(int, input().split()))
	a = int()
	b = int()
	if c[0] >= c[1]:
		a = c[0]
		b = c[1]
	else:
		b = c[0]
		a = c[1]
	if a > 2 * b:
		print('NO')
	else:
		k = a - b
		a = a - 2 * k
		b = b - k
		if a % 3 == 0:
			print('YES')
		else:
			print('NO')


t = int(input())
for i in range(t):
	(a, b) = [int(s) for s in input().split()]
	if a == 1 and b == 1:
		print('NO')
		continue
	if a == 2 * b or b == 2 * a:
		print('YES')
		continue
	if a > 2 * b or b > 2 * a:
		print('NO')
	elif a % 3 == 0 and b % 3 == 0 or (a % 3 == 1 and b % 3 == 2) or (a % 3 == 2 and b % 3 == 1):
		print('YES')
	else:
		print('NO')


import sys
import math
fileoperation = 0
if fileoperation:
	orig_stdout = sys.stdout
	orig_stdin = sys.stdin
	inputfile = open('W:/Competitive Programming/input.txt', 'r')
	outputfile = open('W:/Competitive Programming/output.txt', 'w')
	sys.stdin = inputfile
	sys.stdout = outputfile
mod = 1000000007

def nospace(l):
	ans = ''.join((str(i) for i in l))
	return ans
t = int(input())
for tt in range(t):
	(a, b) = map(int, sys.stdin.readline().split(' '))
	x = 2 * b - a
	y = 2 * a - b
	if x >= 0 and y >= 0 and (x % 3 == 0) and (y % 3 == 0):
		print('YES')
	else:
		print('NO')
if fileoperation:
	sys.stdout = orig_stdout
	sys.stdin = orig_stdin
	inputfile.close()
	outputfile.close()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	if (n + k) % 3 == 0 and min(n, k) * 2 >= max(n, k):
		print('YES')
	else:
		print('NO')


from __future__ import division, print_function
import os
import sys
from io import BytesIO, IOBase
from sys import stdin, stdout
from collections import Counter
from math import ceil
from bisect import bisect_left
from bisect import bisect_right
import math
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def lessThanX(a, x):
	i = bisect_left(a, x)
	if i:
		return i - 1
	else:
		return -1

def BinarySearch(a, x):
	i = bisect_right(a, x)
	if i != len(a) + 1 and a[i - 1] == x:
		return i - 1
	else:
		return -1

def main():
	for i in range(ip()):
		(a, b) = ei()
		if a > b:
			(a, b) = (b, a)
		print('YES' if (a + b) % 3 == 0 and 2 * a >= b else 'NO')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
ip = lambda : int(sys.stdin.readline().rstrip('\r\n'))
ai = lambda : list(map(int, sys.stdin.readline().split()))
ei = lambda : map(int, sys.stdin.readline().split())
main()


n = int(input())
for i in range(n):
	(a, b) = map(int, input().split())
	distance = abs(a - b)
	if distance == min(a, b):
		print('YES')
	elif distance > min(a, b):
		print('NO')
	else:
		same_num = min(a, b) - distance
		if same_num % 3 == 0:
			print('YES')
		else:
			print('NO')


from sys import stdin
from collections import deque
from math import sqrt, floor, ceil, log, log2, log10, pi, gcd, sin, cos, asin

def ii():
	return int(stdin.readline())

def fi():
	return float(stdin.readline())

def mi():
	return map(int, stdin.readline().split())

def fmi():
	return map(float, stdin.readline().split())

def li():
	return list(mi())

def lsi():
	x = list(stdin.readline())
	x.pop()
	return x

def si():
	return stdin.readline()
ans = ['YES', 'NO']
for _ in range(ii()):
	f = 1
	(a, b) = mi()
	if (a or b) and a * b == 0:
		f = 1
	elif a > 2 * b or b > a * 2:
		f = 1
	elif not (a + b) % 3:
		f = 0
	print(ans[f])


n = int(input())
for i in range(n):
	(a, b) = sorted([int(x) for x in input().split()])
	if a * 2 >= b and (a + b) % 3 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(a, b) = [int(i) for i in input().split()]
	if (a + b) % 3 != 0:
		print('NO')
		continue
	sum = (a + b) / 3
	if (sum + (a - b)) % 2 != 0 or sum + (a - b) < 0:
		print('NO')
		continue
	if (sum - (a - b)) % 2 != 0 or sum - (a - b) < 0:
		print('NO')
		continue
	print('YES')


def main():
	n = int(input())
	for i in range(n):
		(a, b) = [int(v) for v in input().split()]
		c = 2 * a - b
		d = 2 * b - a
		if c % 3 == 0 and d % 3 == 0 and (c >= 0) and (d >= 0):
			print('YES')
		else:
			print('NO')

def m1(a, b):
	d1 = a // 2
	a1 = a - 2 * d1
	b1 = b - d1
	return (a1, b1, d1)

def m2(a, b):
	d2 = min(b // 2, a)
	a2 = a - d2
	b2 = b - 2 * d2
	return (a2, b2, d2)
main()


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	if a > b:
		(a, b) = (b, a)
	if (a + b) % 3 == 0 and b <= 2 * a:
		print('YES')
	else:
		print('NO')


n = int(input())
for _ in range(n):
	(a, b) = map(int, input().strip().split())
	f = 0
	x = min(a, b)
	y = max(a, b)
	while True:
		if a > 2 * b or b > 2 * a:
			f = 1
			break
		if a == 0 and b == 0:
			break
		if a <= 0 or b <= 0:
			f = 1
			break
		if x == y:
			if x % 3 == 0 and y % 3 == 0:
				break
			else:
				f = 1
				break
		if y // x == 2:
			break
		mul = (y - x) // 2
		y -= (mul + 1) * 2
		x -= mul + 1
	if f == 0:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	a = sorted([int(x) for x in input().split()])
	(b, c) = a
	if b * 2 >= c and (b + c) % 3 == 0:
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	(a, b) = list(map(int, input().split()))
	if (a + b) % 3 == 0 and b >= a - b and (a >= b - a):
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	if a > b:
		k = b
		b = a
		a = k
	if (a + b) % 3 == 0 and 2 * a >= b:
		print('yes')
	else:
		print('no')


n = int(input())
for _ in range(n):
	(a, b) = map(int, input().split())
	if a > b:
		(a, b) = (b, a)
	if a == 1 and b == 1:
		print('NO')
	elif b > 2 * a:
		print('NO')
	elif (2 * a - b) % 3 == 0:
		print('YES')
	else:
		print('NO')


n = int(input())
for _ in range(n):
	ar = list(map(int, input().split()))
	if ar[0] == 1 and ar[1] == 1:
		print('NO')
	elif ar[0] > 2 * ar[1] or ar[1] > 2 * ar[0]:
		print('NO')
	elif (ar[0] + ar[1]) % 3 != 0:
		print('NO')
	else:
		print('YES')


def main():
	t = int(input())
	for _ in range(t):
		(a, b) = map(int, input().split())
		x1 = 2 * a - b
		x2 = 2 * b - a
		if x1 % 3 == 0 and x2 % 3 == 0 and (x1 >= 0) and (x2 >= 0):
			print('YES')
		else:
			print('NO')
	return
main()


x = int(input())
for f in range(x):
	(a, b) = [int(i) for i in input().split()]
	if a == b and a == 0:
		print('YES')
	elif (a + b) % 3 == 0:
		mi = min(a, b)
		ma = max(a, b)
		if mi * 2 >= ma and (mi != 0 and ma != 0):
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


import sys
input = sys.stdin.readline
N = int(input())
AB = [list(map(int, input().split())) for _ in range(N)]
for (a, b) in AB:
	L = [a, b]
	m = min(L)
	l = max(L)
	if (a + b) % 3 == 0 and l <= m * 2:
		print('YES')
	else:
		print('NO')


cases = int(input())
tests = []
results = []
for i in range(cases):
	tests.append([int(item) for item in input().split()])

def bs(a, b):
	(left, right) = (0, a)
	while left <= right:
		mid = (left + right) // 2
		v1 = a - mid
		v2 = b - 2 * mid
		if v1 == 2 * v2:
			return True
		elif v1 > 2 * v2:
			right = mid - 1
		else:
			left = mid + 1
	return False
for test in tests:
	if bs(test[0], test[1]):
		results.append('YES')
	else:
		results.append('NO')
for result in results:
	print(result)


import os
import sys
from io import BytesIO, IOBase

def solution(a, b):
	write('YES' if (a + b) % 3 == 0 and a * 2 >= b else 'NO')

def main():
	for _ in range(r_int()):
		(a, b) = sorted(r_array())
		solution(a, b)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')

def write(*args, end='\n'):
	for x in args:
		sys.stdout.write(str(x) + ' ')
	sys.stdout.write(end)

def r_array():
	return [int(x) for x in input().split()]

def r_int():
	return int(input())
main()


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	(a, b) = (min(a, b), max(a, b))
	if b > 2 * a:
		print('NO')
		continue
	if b == 2 * a:
		print('YES')
		continue
	rem = b - a
	b = b - 2 * rem
	a = a - rem
	if a % 3 == 0:
		print('YES')
	else:
		print('NO')


import sys
import math
T = int(input())
for _ in range(T):
	(a, b) = map(int, input().split())
	(a, b) = (min(a, b), max(a, b))
	t = a << 1
	if t >= b:
		if (a + b) % 3:
			print('NO')
		else:
			print('YES')
	else:
		print('NO')


t = int(input())
res = []
for i in range(0, t):
	(a, b) = map(int, input().split())
	if (a + b) % 3 != 0 or a * 2 < b or b * 2 < a:
		res.append('NO')
	else:
		res.append('YES')
for r in res:
	print(r)


from sys import stdin

def input():
	return stdin.buffer.readline()
t = int(input())
for i in range(t):
	(a, b) = list(map(int, input().split()))
	if a == 2 * b or b == 2 * a:
		print('YES')
	else:
		x = 2 * a - b
		if x % 3 == 0 and x // 3 < b and (2 * x // 3 < a) and (x // 3 > 0):
			print('YES')
		else:
			x = 2 * b - a
			if x % 3 == 0 and x // 3 < a and (2 * x // 3 < b) and (x // 3 > 0):
				print('YES')
			else:
				print('NO')


for _ in range(int(input())):
	(m, n) = map(int, input().split())
	ch = 0
	(m, n) = (max(m, n), min(m, n))
	if m > 2 * n:
		ch = 0
	else:
		if m % 3 == 0 and n % 3 == 0:
			ch = 1
		d = m - n
		c1 = m - 2 * d
		c2 = n - d
		if c1 % 3 == 0 and c2 % 3 == 0:
			ch = 1
		c1 = m - 1
		c2 = n - 2
		if c1 == 2 * c2 or c2 == 2 * c1:
			ch = 1
		c1 = m - 2
		c2 = n - 1
		if c1 == 2 * c2 or c2 == 2 * c1:
			ch = 1
	if ch == 0:
		print('NO')
	else:
		print('YES')


t = int(input())
for tc in range(t):
	(a, b) = map(int, input().split())
	if [a, b] == [1, 2] or [b, a] == [1, 2] or [a, b] == [0, 0]:
		print('YES')
	else:
		if a > b:
			(a, b) = (b, a)
		diff = b - a
		if a - diff == b - diff * 2 and (a - diff) % 3 == 0 and (a - diff >= 0) and (b - 2 * diff >= 0):
			print('YES')
		else:
			print('NO')


q = int(input())
for i in range(q):
	(x, y) = map(int, input().split(' '))
	if x > y:
		tmp = x
		x = y
		y = tmp
	if x == 0 and y == 0:
		print('YES')
	elif y <= 2 * x and (2 * x - y) % 3 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
EPS = 1e-12
for i in range(t):
	(a, b) = [int(x) for x in input().split()]
	k1 = (-a + 2.0 * b) / 3.0
	k2 = (-b + 2.0 * a) / 3.0
	if k1 < 0 or k2 < 0:
		print('NO')
		continue
	if abs(round(k1) - k1) < EPS:
		print('YES')
	elif abs(round(k2) - k2) < EPS:
		print('YES')
	else:
		print('NO')


from sys import stdin
input = stdin.readline
n = int(input())
for i in range(n):
	(a, b) = map(int, input().split())
	t = [a, b]
	t.sort()
	diff = t[1] - t[0]
	t[1] -= 2 * diff
	t[0] -= diff
	if t[0] % 3 == 0 and t[0] >= 0:
		print('YES')
	else:
		print('NO')


from sys import stdin

def rl():
	return [int(w) for w in stdin.readline().split()]
(t,) = rl()
for _ in range(t):
	(a, b) = rl()
	if a > b:
		(a, b) = (b, a)
	if 2 * a >= b and (a + b) % 3 == 0:
		print('YES')
	else:
		print('NO')


k = int(input())
ans = []
for i in range(k):
	(a, b) = map(int, input().split())
	if a == 0 and b == 0:
		ans.append('Yes')
	elif min(a, b) == 0:
		ans.append('No')
	elif (a + b) % 3 == 0 and max(a, b) / min(a, b) <= 2:
		ans.append('Yes')
	else:
		ans.append('No')
print(*ans, sep='\n')


from sys import stdin, setrecursionlimit
setrecursionlimit(10 ** 6)

def iin():
	return int(stdin.readline())

def lin():
	return list(map(int, stdin.readline().split()))

def main():
	n = iin()
	for _ in range(n):
		(a, b) = lin()
		(x, y) = ((2 * a - b) // 3, (2 * b - a) // 3)
		if x >= 0 and y >= 0 and (a - (2 * x + y) == 0) and (b - (2 * y + x) == 0):
			print('YES')
		else:
			print('NO')
main()


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	x = 2 * b - a
	y = 2 * a - b
	if x % 3 != 0 and y % 3 != 0:
		print('NO')
		continue
	if x < 0 or y < 0:
		print('NO')
		continue
	print('YES')


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	m = max(a, b)
	s = min(a, b)
	d = m - s
	m = m - d * 2
	s = s - d
	if m % 3 == 0 and s % 3 == 0 and (m >= 0) and (s >= 0):
		print('YES')
	else:
		print('NO')


INF = 10 ** 10

def main():
	print = out.append
	(a, b) = get_list()
	(a, b) = (min(a, b), max(a, b))
	if 2 * a - b >= 0 and (2 * a - b) % 3 == 0:
		print('YES')
	else:
		print('NO')
import sys
out = []
get_int = lambda : int(input())
get_list = lambda : list(map(int, input().split()))
[main() for _ in range(int(input()))]
print(*out, sep='\n')


for TT in range(1, int(input()) + 1):
	(a, b) = map(int, input().split())
	res = set([a, b]) == {0}
	if not res and (2 * a - b) % 3 == 0:
		x = (2 * a - b) // 3
		y = (2 * b - a) // 3
		res = x >= 0 and y >= 0
		res &= x > 0 or y > 0
	print(['Yes', 'No'][not res])


import sys

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()

def check(a, b):
	if a > b:
		(a, b) = (b, a)
	if b > 2 * a:
		return False
	if (a + b) % 3 == 0:
		return True
	else:
		return False
T = int(input())
while T:
	mydict = dict()
	(a, b) = get_ints()
	if check(a, b):
		print('YES')
	else:
		print('NO')
	T -= 1


n = int(input())
for i in range(n):
	p = [int(i) for i in input().split()]
	c = p[0]
	s = p[1]
	if (p[0] + p[1]) % 3 != 0 or (c > 2 * s or s > 2 * c):
		print('NO')
	else:
		print('YES')


t = int(input())
while t > 0:
	(a, b) = [int(x) for x in input().split()]
	if (a + b) % 3 != 0 or (a > 2 * b or b > 2 * a):
		print('No')
	else:
		print('Yes')
	t -= 1


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	if a > b:
		(a, b) = (b, a)
	if b > 2 * a:
		print('NO')
		continue
	a = a % 3
	b = b % 3
	if a > b:
		(a, b) = (b, a)
	if a == 1 and b == 2 or (a == b and a == 0):
		print('YES')
	else:
		print('NO')


import sys
sys.setrecursionlimit(10 ** 5 + 1)
inf = int(10 ** 20)
max_val = inf
min_val = -inf
RW = lambda : sys.stdin.readline().strip()
RI = lambda : int(RW())
RMI = lambda : [int(x) for x in sys.stdin.readline().strip().split()]
RWI = lambda : [x for x in sys.stdin.readline().strip().split()]
for _ in range(RI()):
	ab = RMI()
	print('YES' if sum(ab) % 3 == 0 and min(ab) * 2 >= max(ab) else 'NO')


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	flag = True
	if max(x, y) > 2 * min(x, y):
		flag = False
	if (x + y) % 3 != 0:
		flag = False
	if flag:
		print('YES')
	else:
		print('NO')


t = int(input())

def judge():
	if a > b:
		n = b
		m = a
	else:
		n = a
		m = b
	f = m - n
	n -= f
	if n >= 0 and (not n % 3):
		return 1
	return 0
for i in range(t):
	(a, b) = map(int, input().split())
	if not judge():
		print('NO')
	else:
		print('YES')


def optimal(a, b):
	if a == 2 * b or b == 2 * a:
		return 'YES'
	part_one = (2 * a - b) // 3
	part_two = (2 * b - a) // 3
	if part_one <= 0 or part_two <= 0:
		return 'NO'
	if a == part_two + 2 * part_one and b == 2 * part_two + part_one:
		return 'YES'
	return 'NO'

def main():
	num_rooms = int(input())
	answ = []
	for i in range(num_rooms):
		(a, b) = list(map(int, input().split()))
		opt = optimal(a, b)
		answ.append(opt)
	for opt in answ:
		print(opt)
main()


n = int(input())

def getAns(arr):
	a = arr[0]
	b = arr[1]
	if b > 2 * a:
		print('NO')
	elif a > 2 * b:
		print('NO')
	elif (2 * a - b) % 3 == 0:
		print('YES')
	else:
		print('NO')
for i in range(n):
	getAns([int(x) for x in input().split(' ')])


for i in range(int(input())):
	(n, m) = sorted(map(int, input().split()))
	k = n % 3 + m % 3
	if m > 2 * n:
		print('NO')
	elif k % 3 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(a, b) = list(map(int, input().split()))
	if 2 * a < b:
		print('NO')
		continue
	if 2 * b < a:
		print('NO')
		continue
	if (a + b) % 3 == 0:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	(a, b) = sorted(map(int, input().split()))
	print('no' if (a + b) % 3 or b > 2 * a else 'yes')


for qq in range(int(input())):
	(a, b) = map(int, input().split())
	if a + b > 3 * min(a, b):
		print('NO')
	elif (a + b) % 3 != 0:
		print('NO')
		continue
	elif a == b == 0:
		print('YES')
	elif a == 0 or b == 0:
		print('NO')
	else:
		print('YES')


for i in ' ' * int(input()):
	(a, b) = map(int, input().split())
	if (a + b) % 3 == 0:
		if 2 * a >= b and 2 * b >= a:
			print('YES')
			continue
	print('NO')


n = int(input())
for i in range(0, n):
	ln = [int(j) for j in input().split(' ')]
	n = ln[0]
	m = ln[1]
	if n % 2 == 1:
		n -= 1
		m -= 2
	if n == 0 and m == 0:
		print('YES')
		continue
	if n <= 0 or m <= 0:
		print('NO')
		continue
	if (m - n // 2) % 3 == 0 and m * 2 >= n and (m <= n * 2):
		print('YES')
	else:
		print('NO')


for _ in ' ' * int(input()):
	(a, b) = map(int, input().split())
	print('YNEOS'[(max(a, b) + min(a, b)) % 3 != 0 or max(a, b) > 2 * min(a, b)::2])


n = int(input())
for _ in range(n):
	k = 0
	(a, b) = map(int, input().split())
	if a == 0 and b == 0:
		k = 1
	while a > 0 and b > 0:
		if a < b:
			(a, b) = (b, a)
		p = max(1, (a - b) // 2)
		a -= 2 * p
		b -= p
		if a == b and a % 3 != 0:
			break
		elif a == b:
			k += 1
			break
	print('YES' if k == 1 else 'NO')


n = int(input())
ans = []
for _ in range(n):
	(a, b) = map(int, input().split())
	(m, d) = (min(a, b), abs(a - b))
	if (a + b) % 3 == 0 and 2 * b - a >= 0 and (2 * a - b >= 0):
		ans.append('YES')
	else:
		ans.append('NO')
for x in ans:
	print(x)


import sys
n = int(input())
for i in range(n):
	(x, y) = map(int, input().split())
	if (x + y) % 3 != 0:
		print('NO')
	elif min(x, y) * 2 < max(x, y):
		print('NO')
	else:
		print('YES')


for t in range(int(input())):
	(a, b) = sorted(list(map(int, input().split())))
	if b == a * 2:
		print('YES')
	elif (a + b) % 3 == 0 and b <= a * 2:
		print('YES')
	else:
		print('NO')


import sys
readline = sys.stdin.readline
readlines = sys.stdin.readlines
ns = lambda : readline().rstrip()
ni = lambda : int(readline().rstrip())
nm = lambda : map(int, readline().split())
nl = lambda : list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

def solve():
	(a, b) = nm()
	if a < b:
		(a, b) = (b, a)
	s = a - b
	print('YES' if b >= s and (b - s) % 3 == 0 else 'NO')
	return
T = ni()
for _ in range(T):
	solve()


T = int(input())

def read(n):
	s = input().split(' ')
	a = []
	for i in range(n):
		a.append(int(s[i]))
	return a
for Id in range(T):
	(a, b) = read(2)
	if a < b:
		(a, b) = (b, a)
	if a > 2 * b or (b * 2 - a) % 3 != 0:
		print('NO')
	else:
		print('YES')


for i in range(int(input())):
	(a, b) = sorted(map(int, input().split()))
	if 2 * a < b or (a + b) % 3:
		print('NO')
	else:
		print('YES')


for t in range(int(input())):
	(a, b) = sorted([*map(int, input().split())], reverse=True)
	dif = a - b
	print('YES' if (b - dif) % 3 == 0 and b - dif >= 0 else 'NO')


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	x = max(a, b)
	y = min(a, b)
	if x > 2 * y:
		print('NO')
	else:
		diff = x - y
		x -= 2 * diff
		y -= diff
		if x % 3 == 0:
			print('YES')
		else:
			print('NO')


for _ in [0] * int(input()):
	l = list(map(int, input().split()))
	l.sort()
	(a, b) = l
	if 2 * b - a >= 0 and (2 * b - a) % 3 == 0 and (2 * a - b >= 0) and ((2 * a - b) % 3 == 0):
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	(a, b) = list(map(int, input().split()))
	bads = [(1, 0), (1, 1), (2, 2), (2, 3), (3, 2), (3, 0), (0, 3)]
	if a == 0 and b == 0:
		print('YES')
	elif a > 2 * b or b > 2 * a:
		print('NO')
	elif (a + b) % 3 != 0:
		print('NO')
	else:
		print('YES')


t = int(input())
e = [[int(i) for i in input().split()] for i in range(t)]
for List in e:
	a = List[0]
	b = List[1]
	x = (2 * b - a) / 3
	y = (2 * a - b) / 3
	if x >= 0 and y >= 0 and x.is_integer() and y.is_integer():
		print('YES')
	else:
		print('NO')


import sys

def main():
	input_list = []
	for line in sys.stdin:
		input_list.append(line.rstrip('\n'))
	for line in input_list[1:]:
		if solve(int(line.split(' ')[0]), int(line.split(' ')[1])) == True:
			print('YES')
		else:
			print('NO')

def solve(a, b):
	x = (2 * b - a) / 3
	y = (2 * a - b) / 3
	return int(x) == x and int(y) == y and (x >= 0) and (y >= 0)
main()


n = int(input())
for i in range(n):
	(a, b) = map(int, input().split())
	t = b - a
	t1 = max(a, b)
	t2 = min(a, b)
	(a, b) = (t2, t1)
	if b - a > a:
		print('NO')
	elif (b - 2 * (b - a)) % 3 == 0 and 2 * a - b >= 0:
		print('YES')
	else:
		print('NO')


import sys
ip = lambda : sys.stdin.readline().rstrip()
for _ in range(int(ip())):
	(a, b) = map(int, ip().split())
	(a, b) = sorted([a, b])
	if b <= 2 * a and (a + b) % 3 == 0:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	a = 0
	b = 0
	if x > y:
		b = x
		a = y
	else:
		b = y
		a = x
	if a < b / 2:
		print('NO')
	elif b == 2 * a:
		print('YES')
	else:
		res = b - a
		b = b - 2 * res
		a = a - res
		if a % 3 == 0 and b % 3 == 0:
			print('YES')
		else:
			print('NO')


def main():

	def solve():
		(a, b) = map(int, input().split())
		tx = 2 * b - a
		ty = 2 * a - b
		if tx % 3 == 0 and ty % 3 == 0 and (tx >= 0) and (ty >= 0):
			print('YES')
		else:
			print('NO')
	q = int(input())
	for _ in range(q):
		solve()
main()


from sys import *
t = int(stdin.readline())
for _ in range(t):
	(n, k) = map(int, stdin.readline().split())
	a = min(n, k)
	b = max(n, k)
	if (a + b) % 3 == 0 and a * 2 >= b:
		print('YES')
	else:
		print('NO')


a = int(input())
for _ in range(a):
	m = list(map(int, input().split()))
	if m[0] == 1 and m[1] == 1:
		print('NO')
	elif (m[0] + m[1]) % 3 != 0:
		print('NO')
	elif m[0] > 2 * m[1] or m[1] > 2 * m[0]:
		print('NO')
	else:
		print('YES')


from sys import stdin

def solve(tc):
	(a, b) = map(int, stdin.readline().split())
	if a == 0 and b == 0:
		print('YES')
		return
	big = max(a, b)
	small = min(a, b)
	if small == 0 or big > 2 * small or (a + b) % 3 != 0:
		print('NO')
		return
	print('YES')
	pass
LOCAL_TEST = not __debug__
if LOCAL_TEST:
	infile = __file__.split('.')[0] + '-test.in'
	stdin = open(infile, 'r')
tcs = int(stdin.readline().strip())
tc = 1
while tc <= tcs:
	solve(tc)
	tc += 1


from collections import defaultdict, deque
import sys, heapq, bisect, math, itertools, string, queue, copy, time
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
mod = 10 ** 9 + 7
eps = 10 ** (-7)

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

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

def inpl_str():
	return list(sys.stdin.readline().split())
N = inp()
for _ in range(N):
	(a, b) = inpl()
	(a, b) = (min(a, b), max(a, b))
	a = b = a - (b - a)
	if a % 3 == 0 and a >= 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for test in range(t):
	(a, b) = map(int, input().split())
	if a * b == 0 and max(a, b) > 0:
		print('NO')
	elif a == b:
		if a % 3 == 0:
			print('YES')
		else:
			print('NO')
	elif (2 * a - b) % 3 == 0 and 2 * a >= b and (2 * b >= a):
		print('YES')
	else:
		print('NO')


n = int(input())
while n:
	n -= 1
	(a, b) = map(int, input().split())
	if min(a, b) * 2 >= max(a, b):
		print(['YES', 'NO', 'NO'][(a + b) % 3])
	else:
		print('NO')


from sys import stdin, stdout
import math
t = int(stdin.readline().strip())
for _ in range(t):
	(a, b) = list(map(int, stdin.readline().split()))
	if a > b:
		(a, b) = (b, a)
	k = b - a
	if a - k >= 0:
		if (a - k) % 3 == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


n = int(input())
for i in range(n):
	(k, g) = map(int, input().split())
	if k == g == 0:
		print('YES')
		continue
	if (k + g) / 3 - int((k + g) / 3) == 0 and min(k, g) != 0 and (2 * min(k, g) >= max(k, g)):
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(a, b) = list(map(int, input().split()))
	m = max(a, b)
	n = min(a, b)
	if m - n > n:
		print('NO')
	elif (m + n) % 3 == 0:
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	(a, b) = map(int, input().split())
	if a > b:
		(a, b) = (b, a)
	xx = 2 * b - a
	if xx < 0 or xx % 3 != 0:
		print('NO')
		continue
	x = xx // 3
	y = b - 2 * x
	if y < 0:
		print('NO')
		continue
	print('YES')


import sys, io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
for _ in range(int(input())):
	a = [int(i) for i in input().split()]
	a.sort()
	x = a[0]
	y = a[1]
	if x < y // 2:
		print('NO')
		continue
	elif (x + y) % 3 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	if x % 3 == 1 and y % 3 == 2 or (x % 3 == 2 and y % 3 == 1) or (x % 3 == 0 and y % 3 == 0):
		if (x + y) // 3 > min(x, y):
			print('NO')
		else:
			print('YES')
	else:
		print('NO')


def divisors(M):
	d = []
	i = 1
	while M >= i ** 2:
		if M % i == 0:
			d.append(i)
			if i ** 2 != M:
				d.append(M // i)
		i = i + 1
	return d

def popcount(x):
	x = x - (x >> 1 & 1431655765)
	x = (x & 858993459) + (x >> 2 & 858993459)
	x = x + (x >> 4) & 252645135
	x = x + (x >> 8)
	x = x + (x >> 16)
	return x & 127

def eratosthenes(n):
	res = [0 for i in range(n + 1)]
	prime = set([])
	for i in range(2, n + 1):
		if not res[i]:
			prime.add(i)
			for j in range(1, n // i + 1):
				res[i * j] = 1
	return prime

def factorization(n):
	res = []
	for p in prime:
		if n % p == 0:
			while n % p == 0:
				n //= p
			res.append(p)
	if n != 1:
		res.append(n)
	return res

def euler_phi(n):
	res = n
	for x in range(2, n + 1):
		if x ** 2 > n:
			break
		if n % x == 0:
			res = res // x * (x - 1)
			while n % x == 0:
				n //= x
	if n != 1:
		res = res // n * (n - 1)
	return res

def ind(b, n):
	res = 0
	while n % b == 0:
		res += 1
		n //= b
	return res

def isPrimeMR(n):
	d = n - 1
	d = d // (d & -d)
	L = [2, 3, 5, 7, 11, 13, 17]
	for a in L:
		t = d
		y = pow(a, t, n)
		if y == 1:
			continue
		while y != n - 1:
			y = y * y % n
			if y == 1 or t == n - 1:
				return 0
			t <<= 1
	return 1

def findFactorRho(n):
	from math import gcd
	m = 1 << n.bit_length() // 8
	for c in range(1, 99):
		f = lambda x: (x * x + c) % n
		(y, r, q, g) = (2, 1, 1, 1)
		while g == 1:
			x = y
			for i in range(r):
				y = f(y)
			k = 0
			while k < r and g == 1:
				ys = y
				for i in range(min(m, r - k)):
					y = f(y)
					q = q * abs(x - y) % n
				g = gcd(q, n)
				k += m
			r <<= 1
		if g == n:
			g = 1
			while g == 1:
				ys = f(ys)
				g = gcd(abs(x - ys), n)
		if g < n:
			if isPrimeMR(g):
				return g
			elif isPrimeMR(n // g):
				return n // g
			return findFactorRho(g)

def primeFactor(n):
	i = 2
	ret = {}
	rhoFlg = 0
	while i * i <= n:
		k = 0
		while n % i == 0:
			n //= i
			k += 1
		if k:
			ret[i] = k
		i += 1 + i % 2
		if i == 101 and n >= 2 ** 20:
			while n > 1:
				if isPrimeMR(n):
					(ret[n], n) = (1, 1)
				else:
					rhoFlg = 1
					j = findFactorRho(n)
					k = 0
					while n % j == 0:
						n //= j
						k += 1
					ret[j] = k
	if n > 1:
		ret[n] = 1
	if rhoFlg:
		ret = {x: ret[x] for x in sorted(ret)}
	return ret

def divisors(n):
	res = [1]
	prime = primeFactor(n)
	for p in prime:
		newres = []
		for d in res:
			for j in range(prime[p] + 1):
				newres.append(d * p ** j)
		res = newres
	res.sort()
	return res

def xorfactorial(num):
	if num == 0:
		return 0
	elif num == 1:
		return 1
	elif num == 2:
		return 3
	elif num == 3:
		return 0
	else:
		x = baseorder(num)
		return 2 ** x * ((num - 2 ** x + 1) % 2) + function(num - 2 ** x)

def xorconv(n, X, Y):
	if n == 0:
		res = [X[0] * Y[0] % mod]
		return res
	x = [X[i] + X[i + 2 ** (n - 1)] for i in range(2 ** (n - 1))]
	y = [Y[i] + Y[i + 2 ** (n - 1)] for i in range(2 ** (n - 1))]
	z = [X[i] - X[i + 2 ** (n - 1)] for i in range(2 ** (n - 1))]
	w = [Y[i] - Y[i + 2 ** (n - 1)] for i in range(2 ** (n - 1))]
	res1 = xorconv(n - 1, x, y)
	res2 = xorconv(n - 1, z, w)
	former = [(res1[i] + res2[i]) * inv for i in range(2 ** (n - 1))]
	latter = [(res1[i] - res2[i]) * inv for i in range(2 ** (n - 1))]
	former = list(map(lambda x: x % mod, former))
	latter = list(map(lambda x: x % mod, latter))
	return former + latter

def merge_sort(A, B):
	(pos_A, pos_B) = (0, 0)
	(n, m) = (len(A), len(B))
	res = []
	while pos_A < n and pos_B < m:
		(a, b) = (A[pos_A], B[pos_B])
		if a < b:
			res.append(a)
			pos_A += 1
		else:
			res.append(b)
			pos_B += 1
	res += A[pos_A:]
	res += B[pos_B:]
	return res

class UnionFindVerSize:

	def __init__(self, N):
		self._parent = [n for n in range(0, N)]
		self._size = [1] * N
		self.group = N

	def find_root(self, x):
		if self._parent[x] == x:
			return x
		self._parent[x] = self.find_root(self._parent[x])
		stack = [x]
		while self._parent[stack[-1]] != stack[-1]:
			stack.append(self._parent[stack[-1]])
		for v in stack:
			self._parent[v] = stack[-1]
		return self._parent[x]

	def unite(self, x, y):
		gx = self.find_root(x)
		gy = self.find_root(y)
		if gx == gy:
			return
		self.group -= 1
		if self._size[gx] < self._size[gy]:
			self._parent[gx] = gy
			self._size[gy] += self._size[gx]
		else:
			self._parent[gy] = gx
			self._size[gx] += self._size[gy]

	def get_size(self, x):
		return self._size[self.find_root(x)]

	def is_same_group(self, x, y):
		return self.find_root(x) == self.find_root(y)

class WeightedUnionFind:

	def __init__(self, N):
		self.parent = [i for i in range(N)]
		self.size = [1 for i in range(N)]
		self.val = [0 for i in range(N)]
		self.flag = True
		self.edge = [[] for i in range(N)]

	def dfs(self, v, pv):
		stack = [(v, pv)]
		new_parent = self.parent[pv]
		while stack:
			(v, pv) = stack.pop()
			self.parent[v] = new_parent
			for (nv, w) in self.edge[v]:
				if nv != pv:
					self.val[nv] = self.val[v] + w
					stack.append((nv, v))

	def unite(self, x, y, w):
		if not self.flag:
			return
		if self.parent[x] == self.parent[y]:
			self.flag = self.val[x] - self.val[y] == w
			return
		if self.size[self.parent[x]] > self.size[self.parent[y]]:
			self.edge[x].append((y, -w))
			self.edge[y].append((x, w))
			self.size[x] += self.size[y]
			self.val[y] = self.val[x] - w
			self.dfs(y, x)
		else:
			self.edge[x].append((y, -w))
			self.edge[y].append((x, w))
			self.size[y] += self.size[x]
			self.val[x] = self.val[y] + w
			self.dfs(x, y)

class Dijkstra:

	class Edge:

		def __init__(self, _to, _cost):
			self.to = _to
			self.cost = _cost

	def __init__(self, V):
		self.G = [[] for i in range(V)]
		self._E = 0
		self._V = V

	@property
	def E(self):
		return self._E

	@property
	def V(self):
		return self._V

	def add_edge(self, _from, _to, _cost):
		self.G[_from].append(self.Edge(_to, _cost))
		self._E += 1

	def shortest_path(self, s):
		import heapq
		que = []
		d = [10 ** 15] * self.V
		d[s] = 0
		heapq.heappush(que, (0, s))
		while len(que) != 0:
			(cost, v) = heapq.heappop(que)
			if d[v] < cost:
				continue
			for i in range(len(self.G[v])):
				e = self.G[v][i]
				if d[e.to] > d[v] + e.cost:
					d[e.to] = d[v] + e.cost
					heapq.heappush(que, (d[e.to], e.to))
		return d

def Z_algorithm(s):
	N = len(s)
	Z_alg = [0] * N
	Z_alg[0] = N
	i = 1
	j = 0
	while i < N:
		while i + j < N and s[j] == s[i + j]:
			j += 1
		Z_alg[i] = j
		if j == 0:
			i += 1
			continue
		k = 1
		while i + k < N and k + Z_alg[k] < j:
			Z_alg[i + k] = Z_alg[k]
			k += 1
		i += k
		j -= k
	return Z_alg

class BIT:

	def __init__(self, n, mod=0):
		self.BIT = [0] * (n + 1)
		self.num = n
		self.mod = mod

	def query(self, idx):
		res_sum = 0
		mod = self.mod
		while idx > 0:
			res_sum += self.BIT[idx]
			if mod:
				res_sum %= mod
			idx -= idx & -idx
		return res_sum

	def update(self, idx, x):
		mod = self.mod
		while idx <= self.num:
			self.BIT[idx] += x
			if mod:
				self.BIT[idx] %= mod
			idx += idx & -idx
		return

class dancinglink:

	def __init__(self, n, debug=False):
		self.n = n
		self.debug = debug
		self._left = [i - 1 for i in range(n)]
		self._right = [i + 1 for i in range(n)]
		self.exist = [True for i in range(n)]

	def pop(self, k):
		if self.debug:
			assert self.exist[k]
		L = self._left[k]
		R = self._right[k]
		if L != -1:
			if R != self.n:
				(self._right[L], self._left[R]) = (R, L)
			else:
				self._right[L] = self.n
		elif R != self.n:
			self._left[R] = -1
		self.exist[k] = False

	def left(self, idx, k=1):
		if self.debug:
			assert self.exist[idx]
		res = idx
		while k:
			res = self._left[res]
			if res == -1:
				break
			k -= 1
		return res

	def right(self, idx, k=1):
		if self.debug:
			assert self.exist[idx]
		res = idx
		while k:
			res = self._right[res]
			if res == self.n:
				break
			k -= 1
		return res

class SparseTable:

	def __init__(self, A, merge_func, ide_ele):
		N = len(A)
		n = N.bit_length()
		self.table = [[ide_ele for i in range(n)] for i in range(N)]
		self.merge_func = merge_func
		for i in range(N):
			self.table[i][0] = A[i]
		for j in range(1, n):
			for i in range(0, N - 2 ** j + 1):
				f = self.table[i][j - 1]
				s = self.table[i + 2 ** (j - 1)][j - 1]
				self.table[i][j] = self.merge_func(f, s)

	def query(self, s, t):
		b = t - s + 1
		m = b.bit_length() - 1
		return self.merge_func(self.table[s][m], self.table[t - 2 ** m + 1][m])

class BinaryTrie:

	class node:

		def __init__(self, val):
			self.left = None
			self.right = None
			self.max = val

	def __init__(self):
		self.root = self.node(-10 ** 15)

	def append(self, key, val):
		pos = self.root
		for i in range(29, -1, -1):
			pos.max = max(pos.max, val)
			if key >> i & 1:
				if pos.right is None:
					pos.right = self.node(val)
					pos = pos.right
				else:
					pos = pos.right
			elif pos.left is None:
				pos.left = self.node(val)
				pos = pos.left
			else:
				pos = pos.left
		pos.max = max(pos.max, val)

	def search(self, M, xor):
		res = -10 ** 15
		pos = self.root
		for i in range(29, -1, -1):
			if pos is None:
				break
			if M >> i & 1:
				if xor >> i & 1:
					if pos.right:
						res = max(res, pos.right.max)
					pos = pos.left
				else:
					if pos.left:
						res = max(res, pos.left.max)
					pos = pos.right
			elif xor >> i & 1:
				pos = pos.right
			else:
				pos = pos.left
		if pos:
			res = max(res, pos.max)
		return res

def solveequation(edge, ans, n, m):
	x = [0] * m
	used = [False] * n
	for v in range(n):
		if used[v]:
			continue
		y = dfs(v)
		if y != 0:
			return False
	return x

	def dfs(v):
		used[v] = True
		r = ans[v]
		for (to, dire, id) in edge[v]:
			if used[to]:
				continue
			y = dfs(to)
			if dire == -1:
				x[id] = y
			else:
				x[id] = -y
			r += y
		return r

class SegmentTree:

	def __init__(self, init_val, segfunc, ide_ele):
		n = len(init_val)
		self.segfunc = segfunc
		self.ide_ele = ide_ele
		self.num = 1 << (n - 1).bit_length()
		self.tree = [ide_ele] * 2 * self.num
		self.size = n
		for i in range(n):
			self.tree[self.num + i] = init_val[i]
		for i in range(self.num - 1, 0, -1):
			self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1])

	def update(self, k, x):
		k += self.num
		self.tree[k] = x
		while k > 1:
			self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1])
			k >>= 1

	def query(self, l, r):
		if r == self.size:
			r = self.num
		res = self.ide_ele
		l += self.num
		r += self.num
		while l < r:
			if l & 1:
				res = self.segfunc(res, self.tree[l])
				l += 1
			if r & 1:
				res = self.segfunc(res, self.tree[r - 1])
			l >>= 1
			r >>= 1
		return res

	def bisect_l(self, l, r, x):
		l += self.num
		r += self.num
		Lmin = -1
		Rmin = -1
		while l < r:
			if l & 1:
				if self.tree[l] <= x and Lmin == -1:
					Lmin = l
				l += 1
			if r & 1:
				if self.tree[r - 1] <= x:
					Rmin = r - 1
			l >>= 1
			r >>= 1
		if Lmin != -1:
			pos = Lmin
			while pos < self.num:
				if self.tree[2 * pos] <= x:
					pos = 2 * pos
				else:
					pos = 2 * pos + 1
			return pos - self.num
		elif Rmin != -1:
			pos = Rmin
			while pos < self.num:
				if self.tree[2 * pos] <= x:
					pos = 2 * pos
				else:
					pos = 2 * pos + 1
			return pos - self.num
		else:
			return -1
import sys, random, bisect
from collections import deque, defaultdict
from heapq import heapify, heappop, heappush
from itertools import permutations
from math import gcd, log
input = lambda : sys.stdin.readline().rstrip()
mi = lambda : map(int, input().split())
li = lambda : list(mi())
for _ in range(int(input())):
	(a, b) = mi()
	if (a + b) % 3:
		print('NO')
	else:
		k = (a + b) // 3
		t = a - k
		s = b - k
		if 0 <= s and 0 <= t:
			print('YES')
		else:
			print('NO')


from math import *

def inp():
	return map(int, input().split())
for i in range(int(input())):
	(a, b) = inp()
	(mi, ma) = (min(a, b), max(a, b))
	if mi * 2 >= ma and (ma + mi) % 3 == 0:
		print('yes')
	else:
		print('no')


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	if abs(x - y) > min(x, y):
		print('No')
	elif (x + y) % 3 == 0:
		print('Yes')
	else:
		print('No')


from io import BytesIO
import os
input = BytesIO(os.read(0, os.fstat(0).st_size)).readline

def search(a, b):
	left = 0
	right = a
	while left <= right:
		mid = (left + right) // 2
		bigger = 2 * (b - 2 * mid)
		if a - mid == bigger:
			return True
		if a - mid < bigger:
			left = mid + 1
		else:
			right = mid - 1
	return False

def main():
	cases = int(input())
	while cases > 0:
		cases -= 1
		(a, b) = map(int, input().split())
		if a > b:
			(a, b) = (b, a)
		print('YES') if search(a, b) else print('NO')
main()


t = int(input())
for kkk in range(t):
	(a, b) = map(int, input().split())
	if a > 2 * b or b > 2 * a:
		print('NO')
	elif a == 0 and b == 0:
		print('YES')
	elif a == 0 or b == 0:
		print('NO')
	elif (a + b) % 3 == 0:
		print('YES')
	else:
		print('NO')


import sys

def rint():
	return map(int, sys.stdin.readline().split())

def input():
	return sys.stdin.readline().rstrip('\n')

def oint():
	return int(input())
t = oint()
for _ in range(t):
	(A, B) = rint()
	(A, B) = (min(A, B), max(A, B))
	if (A + B) % 3:
		print('NO')
		continue
	ab = (A + B) // 3
	a = A - ab
	b = B - ab
	if a + b == ab and a >= 0 and (b >= 0):
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	(x, y) = map(int, input().split())
	z = abs(y - x)
	if (x + y) % 3 == 0 and abs(x - y) <= min(x, y):
		print('YES')
	else:
		print('NO')


from math import *
from sys import *
from heapq import *
from collections import defaultdict
from itertools import permutations
import os, sys
from io import IOBase, BytesIO
M = 10 ** 9 + 7

def graph_as_tree_1_root():
	n = int(input())
	dict = defaultdict(list)
	for _ in range(n - 1):
		(x, y) = list(map(int, input().split()))
		dict[x].append(y)
		dict[y].append(x)
	tree = [[1]]
	temp = [1]
	vall = 0
	seen = set([i for i in range(2, n + 1)])
	lol = []
	while len(seen) > 0:
		lol = list(seen)
		tt = []
		for x in temp:
			aa = []
			for val in dict[x]:
				if val in seen:
					aa += [val]
					seen.remove(val)
			dict[x] = aa
			tt += aa
		tree.append(tt)
		temp = tt
		vall += 1
	for x in lol:
		dict[x] = []
	print(tree, dict)

def pow(a, b):
	res = 1
	while b > 0:
		if b & 1:
			res *= a
		a *= a
		b >>= 1
	return res

def powmod(a, b, m):
	res = 1
	while b > 0:
		if b & 1:
			res = res * a % m
		a = a * a % m
		b //= 2
	return res

def inv(a, m):
	return powmod(a, m - 2, m)

def alldivisors(n):
	list = []
	arr = []
	for i in range(1, int(sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				arr += [i]
			else:
				arr += [i]
				list.append(n // i)
	arr += list[::-1]
	return arr

def primefactorisation(n):
	potentional_p = 3
	itog_list = defaultdict(int)
	if n % 2 == 0:
		itog_list[2] = 0
	while n % 2 == 0:
		n = n // 2
		itog_list[2] += 1
	while n - 1:
		if potentional_p > n ** 0.5:
			itog_list[n] += 1
			return itog_list
		while n % potentional_p == 0:
			n = n // potentional_p
			itog_list[potentional_p] += 1
		potentional_p += 2
	return itog_list

def meth(a, b):
	lst = [b // a] * a
	b %= a
	for i in range(b):
		lst[i] += 1
	return lst

def main():
	t = int(input())
	for _ in range(t):
		(a, b) = list(map(int, input().split()))
		if (a + b) % 3 != 0:
			print('NO')
		elif abs(a - b) <= (a + b) // 3:
			print('YES')
		else:
			print('NO')
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


for _ in range(int(input())):
	(a, b) = list(map(int, input().split()))
	mi = max(a, b)
	ma = min(a, b)
	if mi // 2 <= ma:
		if any([mi % 3 == 1 and ma % 3 == 2, ma % 3 == 1 and mi % 3 == 2, mi % 3 == 0 and ma % 3 == 0]):
			print('YES')
			continue
	print('NO')


from os import path
import sys
from math import ceil, floor, gcd, log, log2, factorial
from collections import defaultdict, Counter
from itertools import permutations
maxx = float('inf')
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
	I = lambda : int(sys.stdin.buffer.readline())
	tup = lambda : map(int, sys.stdin.buffer.readline().split())
	lint = lambda : [int(x) for x in sys.stdin.buffer.readline().split()]
	S = lambda : sys.stdin.readline().replace('\n', '').strip()

	def grid(r, c):
		return [lint() for i in range(r)]
	stpr = lambda x: sys.stdout.write(f'{x}' + '\n')
	star = lambda x: print(' '.join(map(str, x)))
else:
	I = lambda : int(sys.stdin.buffer.readline())
	tup = lambda : map(int, sys.stdin.buffer.readline().split())
	lint = lambda : [int(x) for x in sys.stdin.buffer.readline().split()]
	S = lambda : sys.stdin.readline().replace('\n', '').strip()

	def grid(r, c):
		return [lint() for i in range(r)]
	stpr = lambda x: sys.stdout.write(f'{x}' + '\n')
	star = lambda x: print(' '.join(map(str, x)))
for _ in range(I()):
	(a, b) = tup()
	if a < b:
		(a, b) = (b, a)
	print('YES') if (a + b) % 3 == 0 and 2 * b >= a else print('NO')


def solve(a, b):
	if a > b:
		(a, b) = (b, a)
	if a == b == 0:
		return 'YES'
	if b > 2 * a:
		return 'NO'
	return 'YES' if (a + b) % 3 == 0 else 'NO'
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	print(solve(a, b))


t = int(input())
for tc in range(t):
	(a, b) = map(int, input().split())
	(x, y) = sorted([a, b])
	diff = y - x
	x -= diff
	y -= 2 * diff
	if x >= 0 and x % 3 == 0 and (y >= 0) and (y % 3 == 0):
		print('YES')
	else:
		print('NO')


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	if (a + b) % 3 or max(a, b) > min(a, b) * 2:
		print('NO')
	else:
		print('YES')


for i in range(int(input())):
	(a, b) = map(int, input().split())
	n = max(a, b)
	m = min(a, b)
	print('Yes' if (a + b) % 3 == 0 and m * 2 >= n else 'No')


test_cases = int(input())
for each_test_case in range(test_cases):
	(a, b) = map(int, input().split())
	a_x_2 = 2 * a
	b_x_2 = 2 * b
	if b <= a_x_2 and a <= b_x_2:
		if (a + b) % 3 == 0:
			print('yes')
		elif a_x_2 == b or b_x_2 == a:
			print('yes')
		else:
			print('no')
	else:
		print('no')


n = int(input())
b = []
for i in range(n):
	a = [x for x in input().split(' ')]
	q = int(a[0])
	w = int(a[1])
	if q >= 0.5 * w and q <= 2 * w and ((2 * q - w) % 3 == 0):
		b.append('YES')
	else:
		b.append('NO')
for i in range(n):
	print(b[i])


T = input()
t = int(T)
i = 0
while i < t:
	N = input()
	sk = N.split(' ')
	a = int(sk[0])
	b = int(sk[1])
	mx = max(a, b)
	mn = min(a, b)
	if mx > 2 * mn or (mx + mn) % 3 != 0:
		print('NO')
	else:
		print('YES')
	i = i + 1


I = input
for _ in range(int(I())):
	(a, b) = map(int, I().split())
	if a == 0 and b == 0:
		print('YES')
	elif a == 0 or b == 0:
		print('NO')
	elif (a + b) % 3 == 0:
		x = (a + b) // 3
		if a >= x and b >= x:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


import math
for _ in range(int(input())):
	ab = list(str(input()).split(' '))
	a = int(ab[0])
	b = int(ab[1])
	lower_limit = math.ceil(a / 2)
	upper_limit = a * 2
	if b >= lower_limit and b <= upper_limit:
		z = (2 * a - b) / 3
		if z == int(z):
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


n = int(input())
for i in range(n):
	(q, w) = map(int, input().split())
	e = 2 * q - w
	if e % 3 == 0:
		a = e // 3
		s = q - 2 * a
		if a >= 0 and s >= 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(a, b) = list(map(int, input().split()))
	if (a + b) % 3 == 0 and abs(a - b) <= min(a, b):
		print('Yes')
	else:
		print('No')


def check(x, y):
	if x > y:
		(x, y) = (y, x)
	if (x + y) % 3 == 0 and 2 * x >= y:
		return 'YES'
	return 'NO'
for _ in range(int(input())):
	(a, b) = [int(i) for i in input().split()]
	print(check(a, b))


n = int(input())
for i in range(0, n):
	(a, b) = map(int, input().split())
	s1 = 2 * a - b
	s2 = 2 * b - a
	if s1 >= 0 and s1 % 3 == 0 and (s2 >= 0) and (s2 % 3 == 0):
		print('YES')
	else:
		print('NO')


from collections import defaultdict
t = int(input())
while t > 0:
	(a, b) = [int(i) for i in input().split()]
	mini = min(a, b)
	if (a + b) % 3 != 0:
		ans = 'NO'
	elif (a + b) // 3 <= mini:
		ans = 'YES'
	else:
		ans = 'NO'
	print(ans)
	t -= 1


def fact(x):
	if x == 0:
		return 1
	else:
		return x * fact(x - 1)

def lower_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] >= num:
			answer = middle
			end = middle - 1
		else:
			start = middle + 1
	return answer

def upper_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] <= num:
			answer = middle
			start = middle + 1
		else:
			end = middle - 1
	return answer

def abs(x):
	return x if x >= 0 else -x

def binary_search(li, val, lb, ub):
	ans = 0
	while lb <= ub:
		mid = (lb + ub) // 2
		if li[mid] > val:
			ub = mid - 1
		elif val > li[mid]:
			lb = mid + 1
		else:
			ans = 1
			break
	return ans

def kadane(x):
	sum_so_far = 0
	current_sum = 0
	for i in x:
		current_sum += i
		if current_sum < 0:
			current_sum = 0
		else:
			sum_so_far = mpos(sum_so_far, current_sum)
	return sum_so_far

def pref(li):
	pref_sum = [0]
	for i in li:
		pref_sum.append(pref_sum[-1] + i)
	return pref_sum

def graph(n, m):
	adj = dict()
	for i in range(1, n + 1):
		adj.setdefault(i, 0)
	for i in range(m):
		(a, b) = map(int, input().split())
		adj[a] += 1
		adj[b] += 1
	return adj
import sys
import threading
from math import *
sys.setrecursionlimit(300000)
threading.stack_size(10 ** 8)
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	if (a + b) % 3 == 0 and 2 * min(a, b) >= max(a, b):
		print('yes')
	else:
		print('no')


import sys
import os.path
if os.path.isfile('in.txt'):
	sys.stdin = open('in.txt', 'r', encoding='utf-8')
t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	if a < b:
		(a, b) = (b, a)
	diff = a - b
	a -= diff * 2
	b -= diff
	if a >= 0 and b >= 0 and (a % 3 == 0):
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	(a, b) = [int(x) for x in input().split()]
	(a, b) = (min(a, b), max(a, b))
	print('yes' if not (a + b) % 3 and 2 * a >= b else 'no')


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(ai, bi) = map(int, input().split())
	if 2 * bi - ai >= 0 and 2 * ai - bi >= 0 and ((2 * bi - ai) % 3 == 0) and ((2 * ai - bi) % 3 == 0):
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	ss = a + b
	if ss % 3 == 0:
		k = ss / 3
		if a >= k and b >= k:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


n = int(input())
for cn in range(1, n + 1):
	(a, b) = map(int, input().split())
	if a > 2 * b or a * 2 < b:
		print('NO')
	elif (a + b) % 3 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
B = [0]
for i in range(t):
	(a, b) = map(int, input().split())
	c = a + b
	d = abs(a - b)
	if c % 3 == 0 and (d <= a and d <= b):
		if a > 0 and b > 0 or c == 0:
			B.append('YES')
		else:
			B.append('NO')
	else:
		B.append('NO')
for i in range(t):
	print(B[i + 1])


T = int(input())
for t in range(T):
	(a, b) = list(map(int, input().split()))
	(mini, maxi) = (min(a, b), max(a, b))
	diff = maxi - mini
	if diff > mini:
		res = 'NO'
	else:
		mini -= diff
		maxi -= 2 * diff
		r1 = mini % 3
		r2 = maxi % 3
		if r1 == 0 and r2 == 0:
			res = 'YES'
		elif r1 == 1 and r2 == 2:
			res = 'YES'
		elif r1 == 2 and r2 == 1:
			res = 'YES'
		else:
			res = 'NO'
	print(res)


t = int(input())
for T in range(t):
	(a, b) = [int(x) for x in input().split()]
	if (a + b) % 3 == 0 and a <= b * 2 <= a * 4:
		print('YES')
	else:
		print('NO')


import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
N = int(input())
for _ in range(N):
	(a, b) = map(int, input().split())
	(a, b) = (min(a, b), max(a, b))
	if (a + b) % 3 == 0 and 2 * a >= b:
		ans = 'Yes'
	else:
		ans = 'No'
	print(ans)


import math
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	flag = False
	if (2 * a - b) % 3 == 0:
		y = (2 * a - b) / 3
		x = a - 2 * y
		if math.floor(x) == math.ceil(x) and x >= 0 and (y >= 0):
			print('Yes')
			flag = True
	if flag != True:
		if (2 * b - a) % 3 == 0:
			y = (2 * b - a) / 3
			x = b - 2 * y
			if math.floor(x) == math.ceil(x) and x >= 0 and (y >= 0):
				print('Yes')
				flag = True
	if flag != True:
		print('No')


n = int(input())
for i in range(n):
	(c, d) = map(int, input().split())
	a = max(c, d)
	b = min(c, d)
	if a == 2 * b:
		print('yes')
	elif a == 0 and b == 0:
		print('yes')
	elif a == 0 or b == 0:
		print('no')
	elif a > 2 * b:
		print('no')
	else:
		a -= 2 * (a % b)
		b -= a % b
		if a % 3 == 0:
			print('yes')
		else:
			print('no')


t = int(input())
for case_num in range(t):
	(a, b) = map(int, input().split(' '))
	if a > b:
		tmp = a
		a = b
		b = tmp
	print('YES' if (a + b) % 3 == 0 and a * 2 >= b else 'NO')


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
mod2 = 998244353
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

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

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

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

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def IF(c, t, f):
	return t if c else f

def YES(c):
	return IF(c, 'YES', 'NO')

def Yes(c):
	return IF(c, 'Yes', 'No')

def main():
	t = I()
	rr = []
	for _ in range(t):
		(a, b) = LI()
		rr.append(YES((a + b) % 3 == 0 and min(a, b) * 3 >= a + b))
	return JA(rr, '\n')
print(main())


t = int(input())
for i in range(0, t):
	(x, y) = map(int, input().split())
	if x == 0 and y == 0:
		print('YES')
	elif x == 0 and y != 0 or (y == 0 and x != 0):
		print('NO')
	elif max(x / y, y / x) > 2:
		print('NO')
	elif (x + y) % 3 == 0:
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	nums = list(map(int, input().split()))
	if (nums[0] + nums[1]) % 3 != 0:
		print('no')
	elif min(nums) < max(nums) - min(nums):
		print('no')
	else:
		print('yes')


t = int(input())
while t:
	t -= 1
	(a, b) = map(int, input().split())
	mi = min(a, b)
	mx = max(a, b)
	if (a + b) % 3 == 0 and 2 * mi >= mx:
		print('YES')
	else:
		print('NO')


t = int(input())
for T in range(t):
	(a, b) = map(int, input().strip().split())
	if b < a:
		(a, b) = (b, a)
	if a * 2 < b:
		print('NO')
	elif a == b and (not a % 3):
		print('YES')
	elif not (2 * a - b) % 3:
		print('YES')
	else:
		print('NO')


import sys
input = sys.stdin.readline
t = int(input())
for i in range(t):
	(a, b) = [int(item) for item in input().split()]
	if (a + b) % 3 != 0:
		print('No')
		continue
	step = (a + b) // 3
	a -= step
	b -= step
	if a < 0 or b < 0:
		print('No')
		continue
	print('Yes')


n = int(input())
for _ in range(n):
	(a, b) = [int(x) for x in input().split(' ')]
	if a == 1 and b == 1 or (a == 2 and b == 2) or a > 2 * b or (b > 2 * a) or ((a + b) % 3 != 0):
		print('NO')
	else:
		print('YES')


def bs(a, b):
	(l, r) = (0, a)
	while l <= r:
		m = (l + r) // 2
		if a - m == 2 * (b - 2 * m):
			return True
		elif a - m < 2 * (b - 2 * m):
			l = m + 1
		else:
			r = m - 1
	return False
n = int(input())
results = []
for i in range(n):
	vals = input().split()
	a = int(vals[0])
	b = int(vals[1])
	if a > b:
		(a, b) = (b, a)
	if bs(a, b):
		results.append('YES')
	else:
		results.append('NO')
for result in results:
	print(result)


import collections
for t in range(int(input())):
	(a, b) = map(int, input().split())
	if a > b:
		(a, b) = (b, a)
	if a == 1:
		if b == 2:
			print('yes')
		else:
			print('no')
		continue
	if 2 * b >= a and (2 * b - a) % 3 == 0:
		x = (2 * b - a) // 3
		if a - x >= 0 and b - 2 * x >= 0 and (a - x == 2 * (b - 2 * x)):
			print('yes')
			continue
	if 2 * a >= b and (2 * a - b) % 3 == 0:
		x = (2 * a - b) // 3
		if b - x >= 0 and a - 2 * x >= 0 and (2 * (a - 2 * x) == b - x):
			print('yes')
			continue
	print('no')


l = []
for i in range(int(input())):
	a = input().split()
	if (int(a[0]) + int(a[1])) % 3 == 0 and abs(int(a[0]) - int(a[1])) <= min(int(a[0]), int(a[1])):
		print('YES')
	else:
		print('NO')


z1 = lambda : map(int, input().split())
z = lambda : input()

def solve():
	(a, b) = z1()
	if (a + b) % 3 == 0 and 2 * min(a, b) >= max(a, b):
		return True
	return False
n = int(z())
for i in range(n):
	print(['no', 'yes'][solve()])


import math
t = int(input())
while t > 0:
	(n, m) = map(int, input().split())
	if n == 0 and m == 0:
		print('YES')
	else:
		k = m + n
		if k % 3 == 0 and max(m, n) <= 2 * min(m, n):
			print('YES')
		else:
			print('NO')
	t -= 1


t = int(input())
pall = []
for i in range(t):
	(a, b) = map(int, input().split())
	if (a + b) % 3 == 0:
		if a <= b:
			if b <= 2 * a:
				pall.append('yes')
			else:
				pall.append('no')
		elif a <= 2 * b:
			pall.append('yes')
		else:
			pall.append('no')
	else:
		pall.append('no')
for k in range(len(pall)):
	print(pall[k])


import bisect
import os
import gc
import sys
from io import BytesIO, IOBase
from collections import Counter
from collections import deque
import heapq
import math
import statistics

def sin():
	return input()

def ain():
	return list(map(int, sin().split()))

def sain():
	return input().split()

def iin():
	return int(sin())
MAX = float('inf')
MIN = float('-inf')
MOD = 1000000007

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	s = set()
	for p in range(2, n + 1):
		if prime[p]:
			s.add(p)
	return s

def readTree(n, m):
	adj = [deque([]) for _ in range(n + 1)]
	for _ in range(m):
		(u, v) = ain()
		adj[u].append(v)
		adj[v].append(u)
	return adj

def main():
	for _ in range(iin()):
		(a, b) = ain()
		if a > b:
			(a, b) = (b, a)
		if (a + b) % 3 == 0 and a * 2 >= b:
			print('YES')
		else:
			print('NO')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
if os.getcwd() == 'D:\\code':
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
	input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


for i in range(int(input())):
	(x, y) = map(int, input().split())
	if not (x + y) % 3 and min(x, y) >= (x + y) // 3:
		print('YES')
	else:
		print('NO')


import sys
import math
import itertools
import collections

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base):
	newnumber = 0
	while number > 0:
		newnumber += number % base
		number //= base
	return newnumber

def cdiv(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def wr(arr):
	return ' '.join(map(str, arr))

def revn(n):
	return str(n)[::-1]

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)
t = ii()
for _ in range(t):
	(a, b) = sorted(mi())
	if (a + b) % 3 != 0 or b > 2 * a:
		print('NO')
	else:
		print('YES')


T = int(input())
for kase in range(T):
	(a, b) = [int(x) for x in input().split()]
	if (-a + 2 * b) % 3 == 0 and (2 * a - b) % 3 == 0 and (-a + 2 * b >= 0) and (2 * a - b >= 0):
		print('yes')
	else:
		print('no')


testCases = int(input())
answerArray = []
for i in range(testCases):
	input1 = list(map(int, input().split(' ')))
	a = input1[0]
	b = input1[1]
	if a > b * 2 or (a + b) % 3 != 0 or b > a * 2:
		answerArray.append('NO')
	else:
		answerArray.append('YES')
for i in answerArray:
	print(i)


x = int(input())
for i in range(x):
	(n, m) = [int(a) for a in input().split()]
	if 2 * min(n, m) < max(m, n) or (n + m) % 3:
		print('NO')
	else:
		print('YES')


import sys, os, io

def rs():
	return sys.stdin.readline().rstrip()

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

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

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math, datetime, functools
from collections import deque, defaultdict, OrderedDict
import collections

def main():
	starttime = datetime.datetime.now()
	if os.path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	zz = 0
	for _ in range(ri()):
		(a, b) = ria()
		(a, b) = (min(a, b), max(a, b))
		x = b - a
		y = a - x
		z = b - 2 * x
		if y == 0 and z == 0 or (y % 3 == 0 and z % 3 == 0 and (max(y, z) >= 3)):
			print('YES')
		else:
			print('NO')
	endtime = datetime.datetime.now()
	time = (endtime - starttime).total_seconds() * 1000
	if os.path.exists('input.txt'):
		print('Time:', time, 'ms')

class FastReader(io.IOBase):
	newlines = 0

	def __init__(self, fd, chunk_size=1024 * 8):
		self._fd = fd
		self._chunk_size = chunk_size
		self.buffer = io.BytesIO()

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self, size=-1):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

class FastWriter(io.IOBase):

	def __init__(self, fd):
		self._fd = fd
		self.buffer = io.BytesIO()
		self.write = self.buffer.write

	def flush(self):
		os.write(self._fd, self.buffer.getvalue())
		(self.buffer.truncate(0), self.buffer.seek(0))

class FastStdin(io.IOBase):

	def __init__(self, fd=0):
		self.buffer = FastReader(fd)
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

class FastStdout(io.IOBase):

	def __init__(self, fd=1):
		self.buffer = FastWriter(fd)
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.flush = self.buffer.flush
sys.stdin = FastStdin()
sys.stdout = FastStdout()
main()


t = int(input())
import math
for j in range(t):
	(a, b) = list(map(int, input().split()))
	if a == 0 and b == 0:
		print('YES')
	elif a == 0 or b == 0:
		print('NO')
	elif (a + b) % 3 == 0 and abs(a - b) <= min(a, b):
		print('YES')
	else:
		print('NO')


T = int(input())
while T > 0:
	(a, b) = [int(x) for x in input().split()]
	if a > b:
		temp = a
		a = b
		b = temp
	if a == b and a % 3 == 0:
		print('YES')
		T -= 1
		continue
	k = b - a - 1
	if k > 0:
		a -= k
		b -= 2 * k
	if a > 0 and b > 1:
		a = a - 1
		b = b - 2
		print('YES' if a % 3 == 0 and b % 3 == 0 else 'NO')
	else:
		print('NO')
	T -= 1


from __future__ import division, print_function

def main():
	import sys
	data = iter(map(int, sys.stdin.buffer.read().decode('ascii').split()))
	n = next(data)
	res = [None] * n
	for i in range(n):
		(a, b) = (next(data), next(data))
		(a, b) = (min(a, b), max(a, b))
		diff = b - a
		b -= 2 * diff
		a -= diff
		if a >= 0 and a % 3 == 0:
			res[i] = 'yes'
		else:
			res[i] = 'no'
	sys.stdout.buffer.write('\n'.join((str(x) for x in res)).encode('ascii'))
	return 0
main()


for i in range(int(input())):
	(x, y) = map(int, input().split())
	if max(x, y) <= 2 * min(x, y):
		if (x + y) % 3 == 0:
			print('yes')
		else:
			print('no')
	else:
		print('no')


def solve(a, b):
	ans = 'YES'
	if a > b:
		(a, b) = (b, a)
	if (a + b) % 3 != 0:
		ans = 'NO'
	elif 2 * a < b:
		ans = 'NO'
	print(ans)

def main():
	t = int(input())
	for i in range(t):
		(a, b) = map(int, input().split())
		solve(a, b)
main()


t = int(input())
while t > 0:
	(a, b) = map(int, input().split())
	ma = max(a, b)
	mi = min(a, b)
	if ma > 2 * mi:
		print('NO')
	elif ma == 2 * mi:
		print('YES')
	else:
		d = ma - mi
		mi = mi - d
		if mi % 3 == 0:
			print('YES')
		else:
			print('NO')
	t = t - 1


tests = int(input())
for t in range(tests):
	(x, y) = list(map(int, input().split(' ')))
	a = (2 * y - x) // 3
	b = (2 * x - y) // 3
	if a + 2 * b == x and 2 * a + b == y and (b >= 0) and (a >= 0):
		print('YES')
	else:
		print('NO')


n = int(input())
for v in range(n):
	(a, b) = input().split()
	a = int(a)
	b = int(b)
	c = min(a, b)
	d = max(a, b)
	if 2 * c >= d and (a + b) % 3 == 0:
		print('YES')
	else:
		print('NO')


n = int(input())
a = []
for i in range(n):
	a.append([int(x) for x in input().split(' ')])
for i in a:
	x1 = i[0]
	x2 = i[1]
	if min(x1, x2) >= abs(x1 - x2):
		nums = min(x1, x2) - abs(x1 - x2)
		if nums == 0:
			print('YES')
		elif nums % 3 == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


for k in range(int(input())):
	t = list(map(int, input().split()))
	if sum(t) % 3 == 0 and min(t) * 2 >= max(t):
		print('YES')
	else:
		print('NO')


T = int(input())
for t in range(T):
	(a, b) = [int(x) for x in input().split()]
	A = min(a, b)
	B = max(a, b)
	if B > 2 * A or (A + B) % 3 != 0:
		print('NO')
	else:
		print('YES')


from __future__ import division, print_function
from io import BytesIO, IOBase
import os, sys, math, heapq, copy
from collections import defaultdict, deque
from bisect import bisect_left, bisect_right
from functools import cmp_to_key
from itertools import permutations, combinations, combinations_with_replacement
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
mod = 1000000007

def get_int():
	return int(sys.stdin.readline().strip())

def get_str():
	return sys.stdin.readline().strip()

def get_float():
	return float(sys.stdin.readline().strip())

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_strs():
	return map(str, sys.stdin.readline().strip().split())

def get_floats():
	return map(float, sys.stdin.readline().strip().split())

def list_ints():
	return list(map(int, sys.stdin.readline().strip().split()))

def list_strs():
	return list(map(str, sys.stdin.readline().strip().split()))

def list_floats():
	return list(map(float, sys.stdin.readline().strip().split()))
t = get_int()
for _ in range(t):
	(a, b) = get_ints()
	if (a + b) % 3 == 0 and (2 * a >= b and 2 * b >= a):
		print('YES')
	else:
		print('NO')


from collections import Counter, deque, defaultdict, OrderedDict, namedtuple
from bisect import bisect_left, bisect_right, insort
from math import sqrt, ceil, floor, factorial, gcd
mod = 10 ** 9 + 7
from sys import stdin
t = int(stdin.readline())
while t:
	(a, b) = map(int, stdin.readline().split())
	k = 'NO'
	if a == 1 and b == 1:
		k = 'NO'
	(b, a) = (max(a, b), min(a, b))
	if b > 2 * a:
		k = 'NO'
	elif (b - 2 + a - 1) % 3 == 0:
		k = 'YES'
	print(k)
	t -= 1


def fastio():
	import sys
	from io import StringIO
	from atexit import register
	global input
	sys.stdin = StringIO(sys.stdin.read())
	input = lambda : sys.stdin.readline().rstrip('\r\n')
	sys.stdout = StringIO()
	register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()

def xrange(n):
	return range(1, n + 1)
MOD = 10 ** 9 + 7
INF = 10 ** 20
I = lambda : list(map(int, input().split()))
from collections import defaultdict as dd
from math import gcd
import string
import heapq
for _ in range(int(input())):
	(a, b) = I()
	y = (2 * a - b) // 3
	x = a - 2 * y
	ans = 'NO'
	if x >= 0 and y >= 0 and (a - x - 2 * y == 0) and (b - y - 2 * x == 0):
		ans = 'YES'
	print(ans)


n = int(input())
for i in range(n):
	ch = input()
	L = [int(i) for i in ch.split()]
	a = L[0]
	b = L[1]
	if a == b:
		if a % 3 == 0:
			print('YES')
		else:
			print('NO')
	if a > b:
		x = a - b
		a = a - 2 * x
		b = b - x
		if a % 3 == 0 and b >= 0 and (a == b):
			print('YES')
		else:
			print('NO')
	elif b > a:
		x = b - a
		b = b - 2 * x
		a = a - x
		if b % 3 == 0 and a >= 0 and (a == b):
			print('YES')
		else:
			print('NO')


import math
from math import gcd as gc
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	(a, b) = (min(a, b), max(a, b))
	if b == 2 * a:
		print('YES')
	elif b > 2 * a or (a - b % a) % 3 != 0:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	(a, b) = sorted(list(map(int, input().split())))
	if b > 2 * a:
		print('NO')
	else:
		print('YES' if (a + b) % 3 == 0 else 'NO')


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	if (a + b) % 3 == 0 and (b * 2 >= a if a > b else a * 2 >= b):
		print('Yes')
	else:
		print('No')


for w in range(int(input())):
	(a, b) = tuple(map(int, input().split()))
	if a == 0 and b == 0:
		print('YES')
	elif a == 0 or b == 0:
		print('NO')
	elif a == b:
		if a % 3 == 0:
			print('YES')
		else:
			print('NO')
	elif b > a:
		if (a + b) % 3 == 0 and b <= 2 * a:
			print('YES')
		else:
			print('NO')
	elif (a + b) % 3 == 0 and a <= 2 * b:
		print('YES')
	else:
		print('NO')


from collections import deque
t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	x = int(a - 2 * ((2 * a - b) / 3))
	y = int((2 * a - b) / 3)
	if 2 * y + x == a and y + 2 * x == b and (x >= 0) and (y >= 0):
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	(a, b) = map(int, input().split())
	if a > b:
		tem = b
		b = a
		a = tem
	if 2 * a >= b and (a + b) % 3 == 0:
		print('YES')
	else:
		print('No')


def solve(a, b):
	if b > 2 * a:
		return 'NO'
	if (a + b) % 3 == 0:
		return 'YES'
	return 'NO'
t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	(a, b) = (min(a, b), max(a, b))
	print(solve(a, b))


n = int(input())
for _ in range(n):
	(a, b) = list(map(int, input().split()))
	ta = max(a, b)
	tb = min(a, b)
	if ta // 2 <= tb:
		if ta % 3 == 1 and tb % 3 == 2:
			print('YES')
			continue
		if tb % 3 == 1 and ta % 3 == 2:
			print('YES')
			continue
		if ta % 3 == 0 and tb % 3 == 0:
			print('YES')
			continue
	print('NO')


from math import ceil
n = int(input())
for i in range(n):
	(a, b) = map(int, input().split())
	if a > b:
		(a, b) = (b, a)
	if 2 * a == b:
		print('YES')
	else:
		lg = b - a + 1
		aa = a - (lg - 1)
		bb = b - (lg - 1) * 2
		if aa < 0 or bb < 0:
			print('NO')
		elif aa % 3 == 0:
			print('YES')
		else:
			print('NO')


import sys
import collections
from collections import Counter
import itertools
import math
import timeit
input = sys.stdin.readline

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	divisors = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				divisors.append(i)
			else:
				divisors.extend([i, n // i])
	return divisors

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def flin(d, x, default=-1):
	left = right = -1
	for i in range(len(d)):
		if d[i] == x:
			if left == -1:
				left = i
			right = i
	if left == -1:
		return (default, default)
	else:
		return (left, right)

def ceil(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def prr(a, sep=' '):
	print(sep.join(map(str, a)))

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)
t = ii()
for _ in range(t):
	(a, b) = mi()
	print('yes') if abs(a - b) <= min(a, b) and (a + b) % 3 == 0 else print('no')


def fun(A, B):
	Max = max(A, B)
	Min = min(A, B)
	if Min * 2 >= Max and (Max + Min) % 3 == 0:
		return True
	else:
		return False
for _ in range(int(input())):
	(A, B) = map(int, input().split())
	if fun(A, B):
		print('YES')
	else:
		print('NO')


import sys
sys.setrecursionlimit(10 ** 7)
from collections import deque
import math
t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	if (a + b) % 3 == 0 and 2 * min(a, b) >= max(a, b):
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(X, Y) = map(int, input().split())
	if X > Y:
		(X, Y) = (Y, X)
	if X == 1 and Y == 1:
		print('NO')
	elif Y > 2 * X:
		print('NO')
	elif (2 * X - Y) % 3 == 0:
		print('YES')
	else:
		print('NO')


T = int(input())
for _ in range(T):
	(N, M) = map(int, input().split())
	if (N + M) % 3 == 0 and 2 * N >= M and (2 * M >= N):
		print('YES')
	else:
		print('NO')


t = int(input())
for nt in range(t):
	(a, b) = [int(k) for k in input().strip().split(' ')]
	if (a + b) % 3 or 2 * a < b or 2 * b < a:
		print('NO')
	else:
		print('YES')


import sys

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7
for _ in range(INT()):
	(a, b) = MAP()
	(a, b) = (min(a, b), max(a, b))
	if a * 2 >= b and (a + b) % 3 == 0:
		YES()
	else:
		NO()


q = int(input())
for i in range(q):
	(w, e) = map(int, input().split())
	(w, e) = sorted((w, e))
	r = e - w
	e -= r * 2
	w -= r
	if e > w:
		e -= 2
		w -= 1
	if w > e:
		w -= 2
		e -= 1
	if e < 0 or w < 0:
		print('NO')
	elif w % 3 == 0:
		print('YES')
	else:
		print('NO')


from sys import stdin
from collections import deque
mod = 10 ** 9 + 7
import sys
from bisect import bisect_right
from bisect import bisect_left
from collections import defaultdict
from math import sqrt, factorial, gcd, log2, inf, ceil
import heapq
input = lambda : sys.stdin.readline().rstrip()
from sys import stdin, stdout
from heapq import heapify, heappush, heappop
t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	(a, b) = (max(a, b), min(a, b))
	if (a + b) % 3 == 0 and a <= 2 * b:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(a, b) = input().split(' ')
	a = int(a)
	b = int(b)
	c = (2 * b - a) / 3
	d = (2 * a - b) / 3
	if c >= 0 and d >= 0:
		if c == int(c) and d == int(d):
			print('Yes')
		else:
			print('No')
	else:
		print('No')


from collections import Counter as C, defaultdict as D, deque as Q
from operator import itemgetter as I
from itertools import product as P, permutations as PERMUT
from bisect import bisect_left as BL, bisect_right as BR, insort as INSORT
from heapq import heappush as HPUSH, heappop as HPOP
from math import floor as MF, ceil as MC, gcd as MG, factorial as F, sqrt as SQRT, inf as INFINITY, log as LOG
from sys import stdin, stdout
INPUT = stdin.readline
PRINT = stdout.write
L = list
M = map

def Player1():
	print('')

def Player2():
	print('')

def Yes():
	PRINT('Yes\n')

def No():
	PRINT('No\n')

def IsPrime(n):
	for i in range(2, MC(SQRT(n)) + 1):
		if n % i == 0:
			return False
	return True

def Factors(x):
	ans = []
	for i in range(1, MC(SQRT(x)) + 1):
		if x % i == 0:
			ans.append(i)
			if x % (x // i) == 0:
				ans.append(x // i)
	return ans

def CheckPath(source, destination, g):
	visited = [0] * 101
	q = Q()
	q.append(source)
	visited[source] = 1
	while q:
		node = q.popleft()
		if node == destination:
			return 1
		for v in g[node]:
			if not visited[v]:
				q.append(v)
				visited[v] = 1
	return 0

def Sieve(n):
	prime = [1] * (n + 1)
	p = 2
	while p * p <= n:
		if prime[p]:
			for i in range(p * p, n + 1, p):
				prime[i] = 0
		p += 1
	primes = []
	for p in range(2, n + 1):
		if prime[p]:
			primes.append(p)
	return primes

def Prefix(a, n):
	p = []
	for i in range(n):
		if i == 0:
			p.append(a[0])
		else:
			p.append(p[-1] + a[i])
	return p

def Suffix(a, n):
	s = [0] * n
	for i in range(n - 1, -1, -1):
		if i == n - 1:
			s[i] = a[i]
		else:
			s[i] = s[i + 1] + a[i]
	return s

def Spf(n):
	spf = [0 for i in range(n)]
	spf[1] = 1
	for i in range(2, n):
		spf[i] = i
	for i in range(4, n, 2):
		spf[i] = 2
	for i in range(3, MC(SQRT(n)) + 1):
		if spf[i] == i:
			for j in range(i * i, n, i):
				if spf[j] == j:
					spf[j] = i
	return spf

def DFS(g, s, visited, ans):
	visited[s] = 1
	for (u, c) in g[s]:
		if visited[u]:
			continue
		if c == ans[s]:
			if c == 1:
				ans[u] = 2
			else:
				ans[u] = 1
		else:
			ans[u] = c
		DFS(g, u, visited, ans)

def lcm(a, b):
	return a * b // MG(a, b)

def Kadane(numbers):
	max_so_far = -INFINITY
	max_ending_here = 0
	max_element = -INFINITY
	for i in range(len(numbers)):
		max_ending_here = max(max_ending_here + numbers[i], 0)
		max_so_far = max(max_ending_here, max_so_far)
		max_element = max(max_element, numbers[i])
	if max_so_far == 0:
		max_so_far = max_element
	return max_so_far

def Main():
	for _ in range(int(INPUT())):
		(a, b) = M(int, INPUT().split())
		(a, b) = (min(a, b), max(a, b))
		if (a + b) % 3 == 0 and 2 * a >= b:
			Yes()
		else:
			No()
Main()