Polycarp has three sisters: Alice, Barbara, and Cerene. They're collecting coins. Currently, Alice has $a$ coins, Barbara has $b$ coins and Cerene has $c$ coins. Recently Polycarp has returned from the trip around the world and brought $n$ coins.

He wants to distribute all these $n$ coins between his sisters in such a way that the number of coins Alice has is equal to the number of coins Barbara has and is equal to the number of coins Cerene has. In other words, if Polycarp gives $A$ coins to Alice, $B$ coins to Barbara and $C$ coins to Cerene ($A+B+C=n$), then $a + A = b + B = c + C$.

Note that A, B or C (the number of coins Polycarp gives to Alice, Barbara and Cerene correspondingly) can be 0.

Your task is to find out if it is possible to distribute all $n$ coins between sisters in a way described above.

You have to answer $t$ independent test cases.


-----Input-----

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

The next $t$ lines describe test cases. Each test case is given on a new line and consists of four space-separated integers $a, b, c$ and $n$ ($1 \le a, b, c, n \le 10^8$) — the number of coins Alice has, the number of coins Barbara has, the number of coins Cerene has and the number of coins Polycarp has.


-----Output-----

For each test case, print "YES" if Polycarp can distribute all $n$ coins between his sisters and "NO" otherwise.


-----Example-----
Input
5
5 3 2 8
100 101 102 105
3 2 1 100000000
10 20 15 14
101 101 101 3

Output
YES
YES
NO
NO
YES

Source: codeforces | Difficulty: EASY
Tags: Mathematics


Solutions:
t = int(input())
for i in range(t):
	(a, b, c, n) = map(int, input().split())
	maximum = max(a, b, c)
	temp = maximum - a + (maximum - b) + (maximum - c)
	n = n - temp
	if n >= 0 and (n / 3).is_integer():
		print('YES')
	else:
		print('NO')


from sys import stdin, stdout
from os import path
if path.exists('inp.txt'):
	stdin = open('inp.txt', 'r')
q = int(stdin.readline())
for _ in range(q):
	(a, b, c, n) = map(int, stdin.readline().split())
	if (n + b + a + c) % 3 != 0:
		stdout.write('NO\n')
	else:
		sum = int((n + a + b + c) / 3)
		if sum < a or sum < b or sum < c:
			stdout.write('NO\n')
		else:
			stdout.write('YES\n')


for _ in range(int(input())):
	(a, b, c, n) = [*map(int, input().split())]
	s = max(a, b, c)
	ans = s - a + (s - b) + (s - c)
	i = n - ans
	if i < 0:
		print('NO')
	elif i % 3 == 0:
		print('Yes')
	else:
		print('NO')


num_tests = int(input())
for _ in range(num_tests):
	(a, b, c, n) = map(int, input().split())
	if (a + b + c + n) % 3 == 0:
		avg = (a + b + c + n) // 3
		if avg >= a and avg >= b and (avg >= c):
			print('YES')
		else:
			print('NO')
	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
from bisect import bisect_left

def solve():
	(a, b, c, n) = sep()
	k = max(a, b, c)
	a = k - a
	b = k - b
	c = k - c
	t = n - a - b - c
	if t >= 0 and t % 3 == 0:
		print('YES')
	else:
		print('NO')
t = int(input())
for _ in range(t):
	solve()


import sys
import bisect as bi
import math
from collections import defaultdict as dd
import heapq
import itertools
input = sys.stdin.readline
from random import randint
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 _ in range(inin()):
	(a, b, c, n) = cin()
	if (a + b + c + n) % 3 == 0:
		if (a + b + c + n) // 3 >= max(a, b, c):
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


from sys import stdin, stdout
from os import path
if path.exists('input.txt'):
	stdin = open('input.txt', 'r')
for _ in range(int(stdin.readline())):
	mylist = list(map(int, stdin.readline().strip().split()))
	mx = max(mylist[:len(mylist) - 1])
	sum = 0
	for i in range(len(mylist) - 1):
		sum += abs(mylist[i] - mx)
	if sum <= mylist[-1] and (mylist[-1] - sum) % (len(mylist) - 1) == 0:
		stdout.write('YES\n')
	else:
		stdout.write('NO\n')


for _ in range(int(input())):
	l = list(map(int, input().split()))
	print('YES' if sum(l) % 3 == 0 and sum(l) / 3 >= max(l[:3]) else 'NO')


t = int(input())
for _ in range(t):
	(a, b, c, n) = map(int, input().split())
	maxm = max(a, max(b, c))
	diff = maxm - a + (maxm - b) + (maxm - c)
	n = n - diff
	if n < 0:
		print('NO')
	elif n % 3 != 0:
		print('NO')
	else:
		print('YES')


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


t = int(input())
ans = []
for i in range(t):
	(a, b, c, n) = [int(x) for x in input().split()]
	maxx = max(a, b, c)
	if maxx == a:
		n -= a - b
		b = a
		if n < a - b:
			ans.append('NO')
			continue
		n -= a - c
		c = a
		if n < a - c:
			ans.append('NO')
			continue
	elif maxx == b:
		n -= b - a
		a = b
		if n < b - a:
			ans.append('NO')
			continue
		n -= b - c
		c = b
		if n < b - c:
			ans.append('NO')
			continue
	elif maxx == c:
		n -= c - a
		a = c
		if n < c - a:
			ans.append('NO')
			continue
		n -= c - b
		b = c
		if n < c - b:
			ans.append('NO')
			continue
	if n % 3 != 0:
		ans.append('NO')
	else:
		ans.append('YES')
for x in ans:
	print(x)


for i in range(int(input())):
	a = list(map(int, input().split()))
	s = sum(a)
	print(['YES', 'NO'][s % -3 | s - 3 * max(a[:3]) < 0])


def solver(arr):
	n = arr.pop(3)
	mi = arr.pop(arr.index(min(arr)))
	ma = arr.pop(arr.index(max(arr)))
	no = arr[0]
	a = ma - mi
	b = ma - no
	if n < a + b:
		return 'NO'
	elif (n - a - b) % 3 == 0:
		return 'YES'
	else:
		return 'NO'
i = int(input())
for j in range(0, i):
	arr = [int(num) for num in input().split()]
	print(solver(arr))


import sys
import heapq
import math
from collections import deque
from collections import defaultdict
from collections import Counter
modH = int(10 ** 9) + 7
I = lambda : list(map(int, input().split(' ')))

def PRINT(lst, sep=' '):
	print(sep.join(map(str, lst)))
for _ in range(int(input())):
	(a, b, c, n) = I()
	ll = (a + b + c + n) / 3
	if (a + b + c + n) % 3 == 0 and ll - a >= 0 and (ll - b >= 0) and (ll - c >= 0):
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(a, b, c, n) = list(map(int, input().split()))
	(a, b, c) = sorted([a, b, c])
	if (a + b + c + n) % 3 == 0 and c - b + (c - a) <= n:
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	(a, b, c, d) = input().split()
	a = int(a)
	b = int(b)
	c = int(c)
	d = int(d)
	maximum = max(a, b, c)
	addition = abs(maximum - a) + abs(maximum - b) + abs(maximum - c)
	if d >= addition:
		difference = d - addition
		if difference % 3 == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


t = int(input())
answer = []
for i in range(t):
	(a, b, c, n) = list(map(int, input().split()))
	flag = True
	if (a + b + c + n) % 3 != 0:
		flag = False
		print('NO')
	else:
		target = (a + b + c + n) // 3
		if target - a < 0 or target - b < 0 or target - c < 0:
			print('NO')
		else:
			print('YES')


k = int(input())
for i in range(1, k + 1):
	x = list(map(int, input().split()))
	t = sum(x)
	y = 0
	if t % 3 != 0:
		print('no')
	else:
		for i in range(0, 3):
			if t / 3 - x[i] < 0:
				print('no')
				y += 1
				break
		if y == 0:
			print('yes')


t = int(input())
for i in range(t):
	a_b_c_n = list(map(int, input().split(' ')))
	a_b_c = a_b_c_n[:-1]
	n = a_b_c_n[-1]
	a_b_c.sort()
	(a, b, c) = a_b_c
	rem = c * 2 - (a + b)
	if rem <= n:
		if (n - rem) % 3 == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


import math
from collections import *
import sys
from functools import reduce

def get_ints():
	return map(int, input().strip().split())

def get_list():
	return list(get_ints())

def get_string():
	return list(input().strip().split())

def printxsp(*args):
	return print(*args, end='')

def printsp(*args):
	return print(*args, end=' ')
UGLYMOD = int(1000000000.0) + 7
SEXYMOD = 998244353
MAXN = int(100000.0)
for _testcases_ in range(int(input())):
	li = get_list()
	flag = True
	if sum(li) % 3:
		flag = False
	else:
		val = sum(li) // 3
		if not all((i <= val for i in li[:-1])):
			flag = False
	print('YES' if flag else 'NO')


for _ in range(int(input())):
	(a, b, c, n) = input().split()
	a = int(a.replace(',', ''))
	b = int(b.replace(',', ''))
	c = int(c.replace(',', ''))
	n = int(n.replace(',', ''))
	m = max(a, b, c)
	s = m - a + (m - b) + (m - c)
	if s > n:
		print('NO')
	else:
		n = n - s
		if n % 3 == 0:
			print('YES')
		else:
			print('NO')


t = int(input())
count = 0
final = []
while count < t:
	poc = []
	coin = input()
	(a, b, c, n) = coin.split(' ')
	poc.append(int(a))
	poc.append(int(b))
	poc.append(int(c))
	h = max(poc)
	n = int(n)
	for x in poc:
		if x < h:
			r = h - x
			x += r
			n -= r
	count += 1
	if n < 0:
		final.append('NO')
	elif n % 3 == 0:
		final.append('YES')
	else:
		final.append('NO')
for y in final:
	print(y)


for i in range(int(input())):
	(a, b, c, n) = map(int, input().split())
	d = max(a, b, c)
	e = a + b + c
	f = 3 * d - e
	g = n - f
	if g % 3 == 0 and g >= 0:
		print('YES')
	else:
		print('NO')


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


for i in range(int(input())):
	(a, b, c, n) = map(int, input().split())
	x = a + b + c + n
	if x % 3 == 0 and max(a, b, c) <= x // 3:
		print('YES')
	else:
		print('NO')


from collections import *
from sys import *
inp = stdin.readline
out = print
t = int(inp())
while t > 0:
	(a, b, c, n) = map(int, inp().split())
	ans = max(a, b, c)
	ans1 = n - (3 * ans - a - b - c)
	if ans1 % 3 == 0 and ans1 >= 0:
		print('YES')
	else:
		print('NO')
	t -= 1


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


t = int(input())
for _ in range(t):
	(a, b, c, n) = map(int, input().split())
	lis = [a, b, c]
	lis.sort()
	x = lis[0]
	y = lis[1]
	z = lis[2]
	xn = z - x
	yn = z - y
	if n >= xn + yn:
		n = n - (xn + yn)
		if n % 3 == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


testCases = int(input())
for case in range(testCases):
	abcn = [int(x) for x in input().split()]
	summ = sum(abcn)
	if summ % 3 == 0 and summ / 3 >= max([abcn[0], abcn[1], abcn[2]]):
		print('YES')
	else:
		print('NO')


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


from sys import stdin

def solve(a: int, b: int, c: int, n: int) -> bool:
	return (a + b + c + n) % 3 == 0 and n - (abs(a - (a + b + c + n) // 3) + abs(b - (a + b + c + n) // 3) + abs(c - (a + b + c + n) // 3)) == 0

def main() -> None:
	t = int(stdin.readline().strip())
	for _ in range(t):
		(a, b, c, n) = map(int, stdin.readline().strip().split())
		print('YES' if solve(a, b, c, n) else 'NO')
main()


t = int(input())
cc = []
for i in range(t):
	s = input()
	s = s.split()
	(a, b, c, n) = (int(s[0]), int(s[1]), int(s[2]), int(s[3]))
	nc = [a, b, c]
	nc = sorted(nc)
	if 2 * nc[2] - nc[0] - nc[1] > n:
		ss = 'NO'
	else:
		n = n - (2 * nc[2] - nc[0] - nc[1])
		ss = 'YES' if n % 3 == 0 else 'NO'
	cc.append(ss)
for i in range(t):
	print(cc[i])


t = int(input())
for cnt in range(t):
	(a, b, c, n) = map(int, input().split())
	if 2 * max(a, b, c) > a + b + c - max(a, b, c) + n:
		print('NO')
		continue
	s = a + b + c + n
	if s % 3 == 0:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	(a, b, c, d) = map(int, input().split())
	lis = []
	lis.append(a)
	lis.append(b)
	lis.append(c)
	lis.sort()
	a = lis[2] - lis[1] + lis[2] - lis[0]
	if a > d:
		print('NO')
	elif (d - a) % 3 == 0:
		print('YES')
	else:
		print('NO')


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


n = int(input())
for i in range(n):
	st = input().split(' ')
	l = len(st)
	s = st[:l - 1]
	for k in range(len(s)):
		s[k] = int(s[k])
	t = st[l - 1]
	t = int(t)
	m = max(s)
	c = 0
	for k in s:
		c = c + m - k
	t = t - c
	if t >= 0:
		if t % 3 == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


for _ in range(int(input())):
	p = list(map(int, input().split()))
	q = sum(p)
	r = q / 3
	if q % 3 == 0 and r >= p[0] and (r >= p[1]) and (r >= p[2]):
		print('YES')
	else:
		print('NO')


from sys import stdin, stdout
fin = lambda : stdin.readline().split()
fout = lambda *args: stdout.write(' '.join((str(i) for i in args)) + '\n')
for _ in range(int(input())):
	(a, b, c, n) = map(int, fin())
	fout('YES' if (a + b + c + n) % 3 == 0 and max([a, b, c]) <= (a + b + c + n) / 3 else 'NO')


for _ in range(int(input())):
	(a, b, c, n) = map(int, input().split())
	l = []
	l.append(a)
	l.append(b)
	l.append(c)
	m = max(l)
	s = 0
	for i in l:
		if i != max:
			s += m - i
	if s <= n:
		if (n - s) % 3 == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


n = int(input())
lines = ''
for line in range(n):
	lines += input() + '\n'
lines = lines.split('\n')
for i in range(len(lines)):
	lines[i] = lines[i].split()
	for j in range(len(lines[i])):
		lines[i][j] = int(lines[i][j])
lines = lines[:-1]
for j in lines:
	i = sorted(j[:-1])
	if i[2] - i[0] + i[2] - i[1] <= j[3] and (j[0] + j[1] + j[2] + j[3]) % 3 == 0:
		print('YES')
	else:
		print('NO')


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


t = int(input())
for _ in range(t):
	(*a, n) = map(int, input().split())
	a.sort(reverse=1)
	k = 0
	for i in range(1, 3):
		k += a[0] - a[i]
	if k <= n and (n - k) % 3 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	s = str(input()).split(' ')
	a = 0
	b = 0
	c = 0
	n = 0
	p = []
	for j in range(len(s)):
		if s[j].strip() != '':
			p.append(int(s[j]))
	a = p[0]
	b = p[1]
	c = p[2]
	n = p[3]
	arr = [a, b, c]
	arr.sort()
	if arr[1] - arr[0] > n:
		print('NO')
	else:
		diff = arr[1] - arr[0]
		n = n - diff
		arr[0] = arr[0] + diff
		if arr[2] - arr[1] == n / 2 and n % 2 == 0:
			print('YES')
		elif 2 * (arr[2] - arr[1]) <= n:
			n = n - 2 * (arr[2] - arr[1])
			arr[1] = arr[2]
			arr[0] = arr[2]
			if n % 3 == 0:
				print('YES')
			else:
				print('NO')
		else:
			print('NO')


t = int(input())
for _ in range(t):
	(a, b, c, n) = map(int, input().split(' '))
	arr = [a, b, c]
	arr = sorted(arr)
	n = n - (arr[-1] - arr[0])
	n = n - (arr[-1] - arr[1])
	if n < 0:
		print('NO')
	elif n % 3 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
while t > 0:
	(a, b, c, n) = map(int, input().split())
	if a == b and a == c:
		if n % 3 == 0:
			print('YES')
		else:
			print('NO')
	else:
		m = [a, b, c]
		m.sort()
		n = n - (m[2] - m[1]) - (m[2] - m[0])
		if n < 0:
			print('NO')
		elif n % 3 == 0:
			print('YES')
		else:
			print('NO')
	t = t - 1


t = int(input())
answer = []
for a in range(t):
	line = [int(i) for i in input().split()]
	n = line[3]
	line.pop(3)
	line.sort()
	a = line[0]
	b = line[1]
	c = line[2]
	if n < 2 * c - b - a:
		answer.append('NO')
	elif (n - 2 * c + b + a) % 3 == 0:
		answer.append('Yes')
	else:
		answer.append('NO')
for b in answer:
	print(b)


for _ in range(int(input())):
	(a, b, c, n) = map(int, input().split())
	A = [a, b, c]
	A.sort()
	t = A[2] - A[1]
	s = A[2] - A[0]
	if n - s - t >= 0 and (n - s - t) % 3 == 0:
		print('YES')
	else:
		print('NO')


def if_distributable(a, b, c, n):
	coins = sorted([a, b, c])
	diff = 2 * coins[2] - coins[1] - coins[0]
	if diff > n or (n - diff) % 3 != 0:
		return 'NO'
	return 'YES'
t = int(input())
for i in range(t):
	(a, b, c, n) = map(int, input().split())
	print(if_distributable(a, b, c, n))


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


for _ in range(int(input())):
	(a, b, c, n) = map(int, input().split())
	output = a + b + c + n
	if output % 3 != 0 or output / 3 < a or output / 3 < b or (output / 3 < c):
		print('NO')
	else:
		print('YES')


t = int(input())
for _ in range(t):
	abcn = list(map(int, input().rstrip().split()))
	a = abcn[0]
	b = abcn[1]
	c = abcn[2]
	n = abcn[3]
	A = (n + b + c - 2 * a) / 3
	B = (n + a + c - 2 * b) / 3
	C = (n + a + b - 2 * c) / 3
	if int(A) == A and int(B) == B and (int(C) == C) and (A >= 0) and (B >= 0) and (C >= 0) and (A + B + C == n) and (A + a == B + b) and (B + b == C + c):
		print('YES')
	else:
		print('NO')


import sys
import math
import heapq
import bisect
import re
from collections import deque
from decimal import *
from fractions import gcd

def main():
	(a, b, c, n) = [int(i) for i in sys.stdin.readline().split()]
	(a, b, c) = sorted([a, b, c])
	f = c - a + c - b
	if (n - f) % 3 == 0 and n - f >= 0:
		print('YES')
		return 0
	print('NO')
for i in range(int(input())):
	main()


t = int(input())
for i in range(t):
	(a, b, c, n) = map(int, input().split(' '))
	each = a + b + c + n / 3
	if (a + b + c + n) % 3 != 0:
		print('NO')
	else:
		each = (a + b + c + n) // 3
		e1 = each - a
		e2 = each - b
		e3 = each - c
		if e1 >= 0 and e2 >= 0 and (e3 >= 0) and (e1 + e2 + e3 == n):
			print('YES')
		else:
			print('NO')


n = int(input())
for i in range(n):
	s = list(map(int, input().split()))
	pol = s[3]
	s.remove(s[3])
	dif = pol - (max(s) - s[0] + max(s) - s[1] + max(s) - s[2])
	if dif % 3 == 0 and dif >= 0:
		print('YES')
	else:
		print('NO')


t = int(input())
while t:
	(a, b, c, n) = map(int, input().split())
	if (a + b + c + n) % 3 == 0 and max(a, b, c) <= (a + b + c + n) // 3:
		print('YES')
	else:
		print('NO')
	t -= 1


def find_maximum(list_of_numbers):
	max = list_of_numbers[0]
	for i in list_of_numbers:
		if i > max:
			max = i
	return max

def find_extra_sum(list_of_numbers, max):
	sum = 0
	for i in list_of_numbers:
		sum = sum + max - i
	return sum
number_of_testcases = int(input())
for i in range(number_of_testcases):
	list_of_numbers = list(map(int, input().split(' ')))
	n = list_of_numbers.pop()
	max = find_maximum(list_of_numbers)
	sum = find_extra_sum(list_of_numbers, max)
	numbers_left = n - sum
	if numbers_left >= 0 and numbers_left % 3 == 0:
		print('YES')
	else:
		print('NO')


count = int(input())
for _ in range(count):
	(a, b, c, n) = map(int, input().split())
	delta1 = max(a, b, c) - a
	delta2 = max(a, b, c) - b
	delta3 = max(a, b, c) - c
	total = delta1 + delta2 + delta3
	if total > n:
		print('NO')
	elif (n - total) % 3 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(a, b, c, n) = map(int, input().split())
	u = max(a, b, c)
	s = 3 * u - a - b - c
	if s > n:
		print('NO')
	elif (n - s) % 3 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())

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


import sys, os
from io import BytesIO, IOBase
import collections, itertools, bisect, heapq, math, string
BUFSIZE = 8192
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')

def main():
	t = int(input())
	for i in range(t):
		abcn = list(map(int, input().split()))
		(a, b, c, n) = (abcn[0], abcn[1], abcn[2], abcn[3])
		s = a + b + c + n
		if s % 3 == 0 and a <= s // 3 and (b <= s // 3) and (c <= s // 3):
			print('YES')
		else:
			print('NO')
main()


for _ in range(int(input())):
	(a, b, c, n) = map(int, input().split())
	x1 = n + a + c - 2 * b
	x2 = n + a + b - 2 * c
	x3 = n + b + c - 2 * a
	if x1 >= 0 and x2 >= 0 and (x3 >= 0) and (x1 // 3 == x1 / 3) and (x2 // 3 == x2 / 3) and (x3 // 3 == x3 / 3):
		print('YES')
	else:
		print('NO')


v = int(input())
while v != 0:
	(a, b, c, n) = map(int, input().split())
	t = a + b + c
	e = (n + t) // 3
	A = e - a
	B = e - b
	C = e - c
	if A + B + C == n and (n + t) % 3 == 0 and (A >= 0) and (B >= 0) and (C >= 0):
		print('YES')
	else:
		print('NO')
	v -= 1


t = input()
t = int(t)
for _ in range(t):
	(a, b, c, n) = input().split()
	a = int(a)
	b = int(b)
	c = int(c)
	n = int(n)
	li = [a, b, c]
	li.sort()
	d = n - (li[2] - li[0]) - (li[2] - li[1])
	if d % 3 == 0 and d >= 0:
		print('yes')
	else:
		print('no')


t = int(input())
for ts in range(t):
	(a, b, c, n) = [int(i) for i in input().split()]
	x = max(a, b, c)
	nn = n - (x - a + x - b + x - c)
	if nn % 3 == 0 and nn >= 0:
		print('YES')
	else:
		print('NO')


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(a, b, c, n) = map(int, input().split())
	cur = max(a, b, c)
	need = cur * 3 - a - b - c
	if need > n or (n - need) % 3:
		print('NO')
	else:
		print('YES')


s = int(input())
for a in range(s):
	(h, i, t, n) = map(int, input().split())
	u = h + i + t + n
	c = max(h, i, t)
	if u % 3 == 0 and c <= u // 3:
		print('Yes')
	else:
		print('No')


test_case = int(input())
for _ in range(test_case):
	(a, b, c, n) = map(int, input().split())
	B = (a - 2 * b + c + n) // 3
	A = b - a + B
	C = b - c + B
	print('YES' if A + B + C == n and A >= 0 and (B >= 0) and (C >= 0) else 'NO')


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


t = int(input())
while t:
	t -= 1
	(a, b, c, n) = map(int, input().split())
	d = max(a, b, c)
	f = d - a + (d - b) + (d - c)
	if f > n:
		print('NO')
		continue
	n -= f
	if n % 3 == 0:
		print('YES')
	else:
		print('NO')


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


n = int(input())
for i in range(n):
	l = []
	l = list(map(int, input().split()))
	s = sum(l)
	if s % 3 != 0:
		print('NO')
	elif max(l[:3]) > s / 3:
		print('NO')
	else:
		print('YES')


n = int(input())
for i in range(n):
	(a, b, c, d) = map(int, input().split())
	lis = [a, b, c]
	z = 0
	for j in lis:
		z = max(lis) - j
		lis[lis.index(j)] = j + z
		d = d - z
	c = 0
	for j in lis:
		if j == max(lis):
			c = c + 1
	if d == 0 and c == 3:
		print('YES')
	elif d % 3 == 0 and d >= 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(a, b, c, n) = map(int, input().split())
	x = max(a, b, c)
	y = min(a, b, c)
	z = a + b + c - x - y
	q = x - y + x - z
	if n >= q and (n - q) % 3 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	flag = 0
	a = list(map(int, input().split()))
	max1 = max(a[0], a[1], a[2])
	for i in range(3):
		res = max1 - a[i]
		a[i] = a[i] + res
		a[3] = a[3] - res
		if a[3] < 0:
			flag = 1
			break
	if flag == 1:
		print('NO')
	elif a[3] % 3 == 0:
		print('YES')
	else:
		print('NO')


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


n = int(input())
for u in range(n):
	(a1, b1, c1, d) = list(map(int, input().split()))
	num = d + b1 + c1 + a1
	if a1 >= b1 and a1 >= c1:
		maxim = a1
		fo = b1 + c1
	elif b1 >= c1 and b1 >= a1:
		maxim = b1
		fo = c1 + a1
	else:
		maxim = c1
		fo = b1 + a1
	if num % 3 == 0 and d >= maxim * 2 - fo:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	l = list(map(int, input().split()))
	if sum(l) % 3 == 0:
		bnk = l[3]
		t = sum(l) // 3
		flag = 0
		for i in l[:3]:
			if i > t:
				flag = 1
				break
		if flag:
			print('NO')
		else:
			print('YES')
	else:
		print('NO')


case = int(input())
for i in range(0, case):
	(x, y, z, n) = [int(x) for x in input().split()]
	target = 3 * max(x, y, z) - (x + y + z)
	if n >= target and (x + y + z + n) % 3 == 0:
		answer = 'YES'
	else:
		answer = 'NO'
	print(answer)


t = int(input())
for i in range(t):
	q = input().split()
	a = int(q[0])
	b = int(q[1])
	c = int(q[2])
	n = int(q[3])
	s = a + b + c
	d = 3 * max(a, b, c) - s
	dif = abs(n - d)
	if dif % 3 == 0 and n >= d:
		print('YES')
	else:
		print('NO')


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


def sint():
	return int(input())

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

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

def sstr():
	s = input()
	return list(s[:len(s)])

def main():
	t = int(input())
	while t:
		t -= 1
		(a, b, c, n) = sints()
		if (a + b + c + n) % 3 == 0 and (a + b + c + n) / 3 >= max(a, b, c):
			print('Yes')
		else:
			print('No')
main()


for i in range(int(input())):
	a = [int(j) for j in input().split()]
	maxe = max(a[0:3])
	sume = 3 * maxe - a[0] - a[1] - a[2]
	if a[-1] == sume:
		print('YES')
	elif a[-1] > sume:
		if (a[-1] - sume) % 3 == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


for i in range(int(input())):
	values = [int(valor) for valor in input().split()]
	n = values.pop()
	values.sort()
	n -= 2 * values[2] - (values[0] + values[1])
	if n < 0 or n % 3 != 0:
		print('NO')
	else:
		print('YES')


t = int(input())
for i in range(t):
	(a, b, c, n) = list(map(int, input().split(' ')))
	sisters = sorted([a, b, c], reverse=True)
	if sisters[0] - sisters[1] + (sisters[0] - sisters[2]) <= n and (n - (sisters[0] - sisters[1] + (sisters[0] - sisters[2]))) % 3 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(a, b, c, n) = map(int, input().split())
	Max = max([a, b, c])
	d = 0
	d += Max - a
	d += Max - b
	d += Max - c
	if n >= d and (n - d) % 3 == 0:
		print('YES')
	else:
		print('NO')


n = int(input().strip())
for i in range(n):
	(a, b, c, n) = [int(x) for x in input().split()]
	Max = max([a, b, c])
	D_sum = 0
	for i in [a, b, c]:
		D_sum += Max - i
	if n - D_sum < 0 or (n - D_sum) % 3 != 0:
		print('NO')
	else:
		print('YES')


import sys
from sys import stdin

def solve():
	q = int(input())
	for i in range(q):
		(a, b, c, n) = [int(x) for x in input().split()]
		li = [a, b, c]
		li.sort()
		n -= 2 * li[2] - li[1] - li[0]
		if n < 0 or n % 3 != 0:
			print('NO')
		else:
			print('YES')

def main():
	solve()
main()


mod = 10 ** 9 + 7
import math
from collections import Counter
from itertools import combinations
import math

def ain():
	return map(int, input().split())
for _ in range(int(input())):
	(a, b, c, n) = ain()
	l = [a, b, c]
	l.sort()
	if 2 * l[2] - l[1] - l[0] > n:
		print('NO')
	elif (n - (2 * l[2] - l[1] - l[0])) % 3 == 0:
		print('YES')
	else:
		print('NO')


for num in range(int(input())):
	(a, b, c, p) = map(int, input().split())
	m = max([a, b, c])
	p = p - (m - a) - (m - b) - (m - c)
	if p % 3 != 0 or p < 0:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	(*l, n) = map(int, input().split())
	m = max(l)
	v = sum(map(lambda x: m - x, l))
	if v <= n and (n - v) % 3 == 0:
		print('YES')
	else:
		print('NO')


nCasos = int(input())
respuestas = []
for i in range(nCasos):
	datos = str(input())
	arregloDatos = list(datos.split())
	monedas = int(arregloDatos[3])
	arregloDatos.pop(3)
	for m in range(len(arregloDatos)):
		arregloDatos[m] = int(arregloDatos[m])
	mayor = 0
	for j in arregloDatos:
		if mayor <= j:
			mayor = j
	for k in range(len(arregloDatos)):
		resta = mayor - arregloDatos[k]
		if resta > 0:
			monedas -= resta
			arregloDatos[k] += resta
	if monedas < 0:
		respuestas.append('NO')
	elif monedas == 0:
		respuestas.append('Yes')
	if monedas > 0:
		if monedas % 3 == 0:
			respuestas.append('Yes')
		else:
			respuestas.append('No')
for i in respuestas:
	print(i)


t = int(input())
for q in range(t):
	(a, b, c, n) = map(int, input().split())
	l = sorted([a, b, c])
	if l[2] - l[1] + l[2] - l[0] > n:
		print('NO')
	elif (n - (l[2] - l[1] + l[2] - l[0])) % 3 != 0:
		print('NO')
	else:
		print('Yes')


import sys
from math import gcd
from heapq import heappop
from heapq import heappush
from heapq import heapify
from bisect import insort
from bisect import bisect_right
from bisect import bisect_left
from sys import stdin, stdout
from collections import defaultdict, deque
from math import log2, ceil, floor
inp = lambda : int(input())
sip = lambda : input()
mulip = lambda : map(int, input().split())
lst = lambda : list(map(int, input().split()))
slst = lambda : list(sip())
arr2d = lambda x: [[int(j) for j in input().split()] for i in range(x)]
odds = lambda l: len(list(filter(lambda x: x % 2 != 0, l)))
evens = lambda l: len(list(filter(lambda x: x % 2 == 0, l)))
mod = pow(10, 9) + 7
Judge = 0
if Judge:
	sys.stdin = open('input.in', 'r')
for i in range(inp()):
	(a, b, c, n) = mulip()
	t = n + a + b + c
	if t % 3 == 0 and t // 3 >= a and (t // 3 >= b) and (t // 3 >= c):
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(a, b, c, n) = map(int, input().split())
	l = []
	l.append(a)
	l.append(b)
	l.append(c)
	l.sort()
	a = l[0]
	b = l[1]
	c = l[2]
	if 2 * c - a - b > n:
		print('NO')
	elif (n + a + b - 2 * c) % 3 == 0 and (n + a + c - 2 * b) % 3 == 0 and ((n + b + c - 2 * a) % 3 == 0):
		print('YES')
	else:
		print('NO')


tcases = int(input())
a = list()
n = list()
for i in range(tcases):
	a.append(list())
	tmp = input().split()
	a[i].append(int(tmp[0]))
	a[i].append(int(tmp[1]))
	a[i].append(int(tmp[2]))
	n.append(int(tmp[3]))
for i in range(tcases):
	sm = 0
	ln = len(a[i])
	mx = max(a[i])
	for j in range(ln):
		sm += mx - a[i][j]
	if sm > n[i]:
		print('NO')
		continue
	n[i] -= sm
	if n[i] % 3 == 0:
		print('YES')
	else:
		print('NO')


import sys
inp = sys.stdin.readline
input = lambda : inp().strip()
flush = sys.stdout.flush

def iin():
	return int(input())

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

def main():
	t = iin()
	while t:
		t -= 1
		(a, b, c, n) = lin()
		if (a + b + c + n) % 3 == 0:
			k = (a + b + c + n) // 3
			if k >= a and k >= b and (k >= c):
				print('YES')
				continue
		print('NO')
main()


t = int(input())
for i in range(t):
	(a, b, c, n) = [int(j) for j in input().split()[:4]]
	m1 = max(a, b, c)
	x1 = m1 - a
	a = x1 + a
	n = n - x1
	x2 = m1 - b
	b = x2 + b
	n = n - x2
	x3 = m1 - c
	c = x3 + c
	n = n - x3
	if a == b == c and n % 3 == 0 and (n >= 0):
		print('YES')
	else:
		print('NO')


def main():
	t = int(input())
	for _ in range(t):
		(a, b, c, n) = map(int, input().split())
		if (a + b + c + n) % 3 != 0:
			print('NO')
			continue
		k = max([(a + b + c + n) // 3, a, b, c])
		if 3 * k - a - b - c > n:
			print('NO')
		else:
			print('YES')
main()


for i in range(int(input())):
	(a, b, c, n) = map(int, input().split())
	d = max(a, b, c)
	a = d - a
	b = d - b
	c = d - c
	need = a + b + c
	n -= need
	if n < 0:
		print('NO')
	elif n % 3 == 0:
		print('YES')
	else:
		print('NO')


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


def do(N):
	for i in range(N):
		tem = list(map(int, input().split()))
		(a, b, c, n) = (tem[0], tem[1], tem[2], tem[3])
		tem_sum = max(a, b, c) * 3 - (a + b + c)
		if tem_sum > n:
			print('NO')
		elif (n - tem_sum) % 3 == 0:
			print('YES')
		else:
			print('NO')
N = int(input())
do(N)


num = int(input())
for i in range(num):
	nums = [int(n) for n in input().split()]
	n = nums[3]
	coins = nums[:3].copy()
	aukaat = False
	i = 0
	while sum(coins) != 3 * max(coins) and n != 0:
		add = max(coins) - coins[i]
		if coins[i] == max(coins):
			i += 1
			continue
		elif n >= add:
			coins[i] += add
			n -= add
		else:
			print('NO')
			aukaat = True
			break
	if aukaat:
		continue
	if sum(coins) == 3 * max(coins) and n == 0:
		print('YES')
	elif sum(coins) == 3 * max(coins) and n % 3 == 0:
		print('YES')
	else:
		print('NO')


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


import sys

def getN():
	return int(input())

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

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

def getArray(intn):
	return [int(input()) for i in range(intn)]

def input():
	return sys.stdin.readline().rstrip()
for _ in range(int(input())):
	(a, b, c, n) = getNM()
	m = max(a, b, c)
	n -= m - a + m - b + m - c
	if n % 3 == 0 and n >= 0:
		print('YES')
	else:
		print('NO')


import sys

def compute_result(a, b, c, n):
	total = a + b + c + n
	if total % 3 != 0:
		print('NO')
		return
	total = total // 3
	A = total - a
	B = total - b
	C = total - c
	if A >= 0 and B >= 0 and (C >= 0):
		print('YES')
	else:
		print('NO')
count = 0
for line in sys.stdin:
	if count == 0:
		count = 1
	else:
		(a, b, c, n) = line.split()
		compute_result(int(a), int(b), int(c), int(n))


t = int(input())
for i in range(t):
	l = list(map(int, input().split()))
	n = l.pop()
	l.sort()
	n -= 2 * l[-1] - l[-2] - l[-3]
	if n >= 0 and n % 3 == 0:
		print('YES')
	else:
		print('NO')


for t in range(int(input())):
	coins = [int(x) for x in input().split()]
	n = coins.pop()
	coins.sort(reverse=True)
	coins[0] *= 2
	even = coins[0] - coins[1] - coins[2]
	if n >= even and (n - even) % 3 == 0:
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	(a, b, c, tcoins) = [int(x) for x in input().split()]
	maxi = max(a, b, c)
	cwanted = 3 * maxi - a - b - c
	if tcoins - cwanted >= 0 and (tcoins - cwanted) % 3 == 0:
		print('YES')
	else:
		print('NO')


def main():
	for _ in range(int(input())):
		(a, b, c, n) = abcn = list(map(int, input().split()))
		(t, r) = divmod(sum(abcn), 3)
		print(('YES', 'NO')[0 < r or t < a or t < b or (t < c)])
main()


t = int(input())
q = int(0)
l = int(0)
for i in range(t):
	(a, b, c, n) = map(int, input().split())
	q = max(a, max(b, c))
	l = q - a + (q - b) + (q - c)
	if (n - l) % 3 == 0 and l <= n:
		print('YES')
	else:
		print('NO')


t = int(input(''))
i = 0
C = []
for i in range(t):
	T = input('').split(' ')
	a = int(T[0])
	b = int(T[1])
	c = int(T[2])
	n = int(T[3])
	avg = (a + b + c + n) / 3
	if a <= avg and b <= avg and (c <= avg) and (avg == int(avg)):
		C.append('YES')
	else:
		C.append('NO')
for a in C:
	print(a)


from sys import stdin as IN
from sys import stdout as OUT
t = int(IN.readline())
for _ in range(t):
	(a, b, c, n) = map(int, IN.readline().split())
	if (a + b + c + n) % 3 != 0:
		print('NO')
		continue
	coins = (a + b + c + n) // 3
	if a > coins or b > coins or c > coins:
		print('NO')
		continue
	print('YES')


t = int(input())
for x in range(t):
	(a, b, c, n) = map(int, input().split())
	t = [a, b, c]
	t = sorted(t, reverse=True)
	if t[0] - t[1] + (t[0] - t[2]) > n or (n - (t[0] - t[1] + (t[0] - t[2]))) % 3 != 0:
		print('NO')
	else:
		print('YES')


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


t = int(input())
for i in range(t):
	n = [int(i) for i in input().split()]
	if (n[0] + n[1] + n[2] + n[3]) % 3 == 0:
		ma = 0
		for i in [n[1], n[2], n[0]]:
			if i > ma:
				ma = i
		dif = 0
		for i in [n[1], n[2], n[0]]:
			dif += ma - i
		if n[3] >= dif:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(a, b, c, n) = map(int, input().split())
	ma = max(a, b, c)
	sum = ma - a + (ma - b) + (ma - c)
	if n - sum < 0:
		print('NO')
	elif (n - sum) % 3 == 0:
		print('YES')
	else:
		print('NO')


from sys import stdin
input = stdin.readline
for _ in range(int(input())):
	(a, b, c, d) = map(int, input().split())
	l = [a, b, c]
	l.sort()
	m = l[-1]
	ans = 0
	for i in range(3):
		if m - l[i] <= d:
			d -= m - l[i]
			l[i] = m
		else:
			ans = -1
			break
	if d % 3 == 0 and ans == 0:
		print('YES')
	else:
		print('NO')


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


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


n = int(input())
l1 = []
for i in range(n):
	l1.append([int(x) for x in input().split()])

def ans(a, b, c, d):
	if (a + b + c + d) % 3 != 0:
		return 'NO'
	else:
		e = (a + b + c + d) // 3
		if e < max(a, b, c):
			return 'NO'
		else:
			return 'YES'
for i in range(n):
	print(ans(l1[i][0], l1[i][1], l1[i][2], l1[i][3]))
print()


T = int(input())
for i in range(T):
	tmp = list(map(int, input().split()))
	sisters = tmp[:3]
	n = tmp[-1]
	sisters.sort()
	diff_1 = sisters[2] - sisters[0]
	diff_2 = sisters[2] - sisters[1]
	sisters[0] += diff_1
	sisters[1] += diff_2
	n -= diff_1 + diff_2
	if n >= 0 and n % 3 == 0:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	l = list(map(int, input().split()))
	q = sum(l) // 3
	if sum(l) % 3 == 0:
		if q - l[0] >= 0 and q - l[1] >= 0 and (q - l[2] >= 0):
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(a, b, c, n) = [int(j) for j in input().split()]
	d = [a, b, c]
	d.sort()
	if n < 2 * d[2] - d[1] - d[0]:
		print('NO')
	else:
		n -= 2 * d[2] - d[1] - d[0]
		if n % 3 == 0:
			print('YES')
		else:
			print('NO')


def main():
	t = int(input())
	for _ in range(t):
		(a, b, c, n) = map(int, input().split())
		k = (a + b + c + n) // 3
		A = k - a
		B = k - b
		C = k - c
		if min(A, B, C) < 0 or A + B + C != n:
			print('NO')
		else:
			print('YES')
	return
main()


t = int(input())
for i in range(t):
	a = list(map(int, input().split()))
	b = a[3]
	del a[3]
	a.sort()
	c = a[2] - a[0]
	d = a[2] - a[1]
	r = b - (c + d)
	if r < 0:
		print('NO')
	elif r % 3 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for test in range(t):
	(a, b, c, n) = map(int, input().split())
	req = 3 * max(a, b, c) - (a + b + c)
	if req <= n and (n - req) % 3 == 0:
		print('YES')
	else:
		print('NO')


from sys import stdin, stdout
for _ in range(int(stdin.readline())):
	(a, b, c, n) = list(map(int, stdin.readline().split()))
	if (a + b + c + n) % 3 == 0:
		each = (a + b + c + n) // 3
		if each >= a and each >= b and (each >= c) and (each - a + each - b + each - c == n):
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


import math
for _ in range(int(input())):
	a = list(map(int, input().split()))
	l = []
	for i in range(3):
		l.append(a[i])
	l.sort()
	count = l[2] - l[0] + l[2] - l[1]
	net = a[3] - count
	if net >= 0 and net % 3 == 0:
		print('YES')
	else:
		print('NO')


n = int(input())
for t in range(n):
	moeda = list(map(int, input().split()))
	poli = moeda[3]
	del moeda[3]
	moedaMenor1 = min(moeda)
	moeda.remove(moedaMenor1)
	moedaMenor2 = min(moeda)
	moeda.remove(moedaMenor2)
	dif = moeda[0] - moedaMenor1 + (moeda[0] - moedaMenor2)
	if dif <= poli:
		poli -= dif
		if poli % 3 == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(a, b, c, d) = list(map(int, input().split()))
	m = max([a, b, c])
	m = m - a + (m - b) + (m - c)
	if m % 3 == d % 3 and d >= m:
		print('YES')
	else:
		print('NO')


t = int(input())
for case in range(t):
	(a, b, c, n) = [int(s) for s in input().split(' ')]
	x = a + b + c + n
	if not x % 3 == 0 or max(a, b, c) > x / 3:
		print('NO')
	else:
		print('YES')


def polycarb(lst, n):
	lst.sort()
	if lst[0] == lst[1] == lst[2]:
		if n % 3 == 0:
			return 'YES'
		else:
			return 'NO'
	diff = lst[2] - lst[1]
	if n >= diff:
		lst[1] += diff
		n = n - diff
	else:
		return 'NO'
	diff2 = lst[1] - lst[0]
	if n >= diff2:
		lst[0] += diff2
		n = n - diff2
	else:
		return 'NO'
	if n % 3 == 0:
		return 'YES'
	else:
		return 'NO'
t = int(input())
for i in range(t):
	ar = list(map(int, input().split()))
	print(polycarb(ar[:3], ar[3]))


inp = lambda : map(int, input().split())
t = int(input())
for _ in range(t):
	(a, b, c, n) = inp()
	print('YNEOS'[((a + b + c + n) % 3 > 0) | (max(a, b, c) > (a + b + c + n) / 3)::2])


import math, collections, sys
input = sys.stdin.readline
for _ in range(int(input())):
	(a, b, c, n) = map(int, input().split())
	if (a + b + c + n) % 3 == 0:
		final = (a + b + c + n) // 3
		if final >= a and final >= b and (final >= c):
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


t = int(input())
for i in range(t):
	c = list(map(int, input().split()))
	if sum(c) % 3 == 0 and max(c[:len(c) - 1]) <= int(sum(c) / 3):
		print('YES')
	else:
		print('NO')


for t in range(int(input())):
	[a, b, c, n] = list(map(int, input().split()))
	maximum = max(a, b, c)
	diff = maximum - a + (maximum - b) + (maximum - c)
	if (n - diff) % 3 == 0 and n >= diff:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(a, b, c, n) = map(int, input().split())
	B = n + a - 2 * b + c
	if B % 3 != 0 or B < 0:
		print('NO')
		continue
	B = B // 3
	C = n + a + b - 2 * c
	if C % 3 != 0 or C < 0:
		print('NO')
		continue
	C = C // 3
	A = n - B - C
	if A < 0:
		print('NO')
		continue
	print('YES')


t = int(input())
for _ in range(t):
	(a, b, c, n) = map(int, input().split())
	tot = a + b + c + n
	if tot % 3:
		print('NO')
	else:
		des = tot // 3
		if a > des or b > des or c > des:
			print('NO')
		else:
			print('YES')


from collections import defaultdict
import bisect
import math
x = int(input())
for _ in range(x):
	(a, b, c, d) = map(int, input().split())
	e = max(a, b, c)
	d -= abs(a - e)
	d -= abs(b - e)
	d -= abs(c - e)
	a = e
	b = e
	c = e
	a += d // 3
	b += d // 3
	c += d // 3
	if d % 3 == 0 and d >= 0 and (a == b == c):
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	arr = list(map(int, input().split()))
	li = [arr[0], arr[1], arr[2]]
	li.sort(reverse=True)
	a = li[0]
	b = li[1]
	c = li[2]
	x = 2 * a - (b + c)
	dif = arr[3] - x
	if dif % 3 == 0 and dif >= 0:
		print('YES')
	else:
		print('NO')


def djevel(lst, d):
	x = 2 * lst[-1] - lst[0] - lst[1]
	if x > d:
		return 'NO'
	n = d - x
	return 'YES' if n % 3 == 0 else 'NO'
for _ in range(int(input())):
	(a, b, c, n) = [int(i) for i in input().split()]
	print(djevel(sorted([a, b, c]), n))


t = int(input())
for _ in range(t):
	(*a, n) = map(int, input().split())
	a.sort()
	n -= 2 * a[2] - a[1] - a[0]
	if n < 0 or n % 3 != 0:
		print('NO')
	else:
		print('YES')


t = int(input())
for _ in range(t):
	(a, b, c, n) = map(int, input().split())
	(a, b, c) = sorted([a, b, c], reverse=True)
	diff_sum = a - b + a - c
	if diff_sum <= n and (n - diff_sum) % 3 == 0:
		print('YES')
	else:
		print('NO')


n_tests = int(input())
for i in range(n_tests):
	curr = input().split()
	n = int(curr[3])
	coin_counts = [int(curr[i]) for i in range(3)]
	needed_coins = max(coin_counts) * 3
	for j in coin_counts:
		needed_coins -= j
	if needed_coins <= n and (n - needed_coins) % 3 == 0:
		print('YES')
	else:
		print('NO')


number_of_test_cases = int(input())
for i in range(number_of_test_cases):
	(a, b, c, n) = [int(i) for i in input().split()]
	list = sorted([a, b, c])
	sum = list[-1] - list[1] + (list[-1] - list[0])
	if (a + b + c + n) % 3 == 0 and sum <= n:
		print('YES')
	else:
		print('NO')


import sys
input = sys.stdin.readline

def cin():
	return int(input())

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

def caso():
	(a, b, c, n) = cin_()
	lista = [a, b, c]
	lista = sorted(lista)
	n -= lista[2] - lista[1]
	n -= lista[2] - lista[0]
	if n < 0:
		print('NO')
	elif n % 3 == 0:
		print('YES')
	else:
		print('NO')
t = cin()
for i in range(t):
	caso()


t = int(input())
for i in range(t):
	(a, b, c, n) = map(int, input().split())
	m = max(a, b, c)
	k1 = m - a
	k2 = m - b
	k3 = m - c
	n = n - k1 - k2 - k3
	if n % 3 == 0 and n >= 0:
		print('YES')
	elif n == 0 and k1 == 0 and (k2 == 0) and (k3 == 0):
		print('YES')
	elif n == 0 and k1 != k2 != k3:
		print('NO')
	else:
		print('NO')


n = int(input())
for i in range(n):
	a = [int(i) for i in input().split(' ')]
	count = sum(a)
	if count % 3 == 0:
		mean = count / 3
		if a[0] > mean or a[1] > mean or a[2] > mean:
			print('NO')
		else:
			print('YES')
	else:
		print('NO')


res = []
t = int(input())
for i in range(t):
	data = input().split(' ')
	a = int(data[0])
	b = int(data[1])
	c = int(data[2])
	n = int(data[3])
	aux = 3 * max(a, b, c) - a - b - c
	if n < aux:
		res.append('NO')
	elif (n - aux) % 3 == 0:
		res.append('YES')
	else:
		res.append('NO')
for value in res:
	print(value)


t = int(input())
while t > 0:
	(a, b, c, n) = map(int, input().split())
	(a, b, c) = sorted([a, b, c])
	m = 3 * c - sum([a, b, c])
	if n < m:
		print('NO')
		t = t - 1
		continue
	r = n - m
	if r == 0:
		print('YES')
		t = t - 1
		continue
	if r % 3 == 0:
		print('YES')
	else:
		print('NO')
	t = t - 1


import sys
import math
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(a, b, c, n1) = map(int, input().split())
	maxi = max(a, max(b, c))
	flag = 0
	n = n1
	if maxi - a <= n:
		n = n - maxi + a
		a = maxi
	else:
		flag = 1
	if maxi - b <= n:
		n = n - maxi + b
		b = maxi
	else:
		flag = 1
	if maxi - c <= n:
		n = n - maxi + c
		c = maxi
	else:
		flag = 1
	if flag:
		print('NO')
	elif n % 3 == 0:
		print('YES')
	else:
		print('NO')


from sys import stdin, stdout, exit as sys_ret
(f_input, f_print, f_flush) = (stdin.readline, stdout.write, stdout.flush)
for _ in range(int(f_input())):
	Input = [int(i) for i in f_input().split()]
	(amount, Input) = (Input[3], sorted(Input[:3]))
	amount -= Input[2] * 2 - Input[1] - Input[0]
	if amount < 0:
		f_print('NO\n')
		continue
	if amount % 3 == 0:
		f_print('YES\n')
	else:
		f_print('NO\n')


for q in range(int(input())):
	(a, b, c, d) = list(map(int, input().split()))
	v = [a, b, c]
	v.sort()
	total = a + b + c + d
	if total % 3 == 0 and abs(v[2] - v[1]) + abs(v[2] - v[0]) <= d:
		print('YES')
	else:
		print('NO')


t = int(input())
for x in range(t):
	arr = list(map(int, input().split()))
	arr2 = arr[:3]
	arr2.sort()
	sumofdif = arr2[2] - arr2[0] + (arr2[2] - arr2[1])
	sub = arr[3] - sumofdif
	if sub % 3 == 0 and arr[3] >= sumofdif:
		print('YES')
	else:
		print('NO')


import sys
import os
import time
import collections
from collections import Counter, deque
import itertools
import math
import timeit
import random

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)
input = sys.stdin.readline
res = []
for _ in range(ii()):
	(*d, n) = mi()
	d.sort()
	n -= 2 * d[2] - d[0] - d[1]
	r = 'NO' if n < 0 or n % 3 else 'YES'
	res.append(r)
prr(res, '\n')


import sys
import math

def main():
	for _ in range(int(input())):
		(a, b, c, n) = [int(x) for x in sys.stdin.readline().split()]
		x = max(a, b, c)
		A = x - a
		B = x - b
		C = x - c
		x = A + B + C
		if n < x:
			print('NO')
		else:
			n = n - x
			if n % 3 == 0:
				print('YES')
			else:
				print('NO')
main()


for i in range(int(input())):
	(a, b, c, n) = map(int, input().split())
	yy = -2 * a + b + c + n
	r = yy % 3
	A = yy // 3
	B = a - b + A
	C = b - c + B
	print('YES' if r == 0 and A >= 0 and (B >= 0) and (C >= 0) else 'NO')


for _ in range(int(input())):
	(a, b, c, n) = map(int, input().split())
	s = max(a, b, c)
	x = 0
	s1 = s - a
	x = x + s1
	s2 = s - b
	x = x + s2
	s3 = s - c
	x = x + s3
	if n >= x:
		n = n - x
		if n % 3 == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


n = int(input())
for i in range(n):
	(a, b, c, n) = map(int, input().strip().split())
	m = max(a, b, c)
	ns = n + a + b + c - 3 * m
	if ns < 0:
		print('No')
	elif ns % 3 != 0:
		print('No')
	else:
		print('Yes')


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


cases = int(input())

def solve(a, b, c, n):
	s = a + b + c + n
	if s % 3 != 0:
		return 'NO'
	else:
		s = s // 3
		if s < a or s < b or s < c:
			return 'NO'
	return 'YES'
for i in range(cases):
	(a, b, c, n) = map(int, input().split())
	print(solve(a, b, c, n))


n = int(input())
for i in range(n):
	L = [int(el) for el in input().split()]
	if sum(L) % 3 != 0:
		print('NO')
	elif L[3] - (max(L[:3]) - L[0] + max(L[:3]) - L[1] + max(L[:3]) - L[2]) == 0:
		print('YES')
	elif L[3] - (max(L[:3]) - L[0] + max(L[:3]) - L[1] + max(L[:3]) - L[2]) > 0:
		if (L[3] - (max(L[:3]) - L[0] + max(L[:3]) - L[1] + max(L[:3]) - L[2])) % 3 == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


N = int(input())
M = []
for i in range(N):
	(a, b, c, n) = map(int, input().split())
	lis = [a, b, c]
	nlis = sorted(lis, reverse=True)
	cou = nlis[0] - nlis[1] + nlis[0] - nlis[2]
	if cou <= n:
		if (a + b + c + n) % 3 == 0:
			M.append('YES')
		else:
			M.append('NO')
	else:
		M.append('NO')
for k in M:
	print(k)


def solution(a, b, c, n):
	m = max(a, b, c)
	s = 3 * m - a - b - c
	n -= s
	return not (n < 0 or n % 3)
t = int(input())
for i in range(t):
	(a, b, c, n) = map(int, input().split())
	print('YES' if solution(a, b, c, n) else 'NO')


for i in range(int(input())):
	l = list(map(int, input().split()))
	n = l[3]
	del l[3]
	m = max(l)
	for j in range(3):
		k = m - l[j]
		if n < k:
			break
		else:
			l[j] = m
		n = n - k
		if n == 0:
			break
	s = set(l)
	if len(s) == 1:
		if n % 3 == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


for i in range(int(input())):
	(a, b, c, d) = map(int, input().split())
	l = max([a, b, c])
	p = l - a + l - b + l - c
	q = d - p
	if q >= 0 and q % 3 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
while t > 0:
	(a, b, c, n) = map(int, input().split())
	if (n + a + b + c) % 3 != 0:
		print('NO')
	else:
		X = (n + a + b + c) / 3
		if X - a < 0:
			print('NO')
		elif X - b < 0:
			print('NO')
		elif X - c < 0:
			print('NO')
		else:
			print('YES')
	t -= 1


t = int(input())
data = [list(map(int, input().split())) for i in range(t)]
for i in range(t):
	(a, b, c, n) = (data[i][0], data[i][1], data[i][2], data[i][3])
	top = max((a, b, c))
	div = 3 * top - (a + b + c)
	if div > n:
		print('NO')
		continue
	elif (div - n) % 3 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(a, b, c, n) = [int(i) for i in input().split()]
	m = max(a, b, c)
	av = m * 3 - (a + b + c)
	if av <= n and (n - av) % 3 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for T in range(t):
	arr = []
	(a, b, c, n) = map(int, input().split())
	arr.append(a)
	arr.append(b)
	arr.append(c)
	arr.sort()
	c = arr[0]
	b = arr[1]
	a = arr[2]
	B = a - b
	C = a - c
	if n - (B + C) >= 0 and (n - (B + C)) % 3 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
while t > 0:
	t -= 1
	l = list(map(int, input().split()))
	n = l[3]
	l.remove(n)
	l.sort()
	if n < 2 * l[2] - l[1] - l[0]:
		print('NO')
	else:
		n -= 2 * l[2] - l[1] - l[0]
		if n >= 0 and n % 3 == 0:
			print('YES')
		else:
			print('NO')


import array
import math
import os
import random
import re
import sys
ss = input()
n = int(ss)
for i in range(0, n, 1):
	aa = array.array('l', [])
	aa = [int(i) for i in input().split()]
	a = int(aa[0])
	b = int(aa[1])
	c = int(aa[2])
	dd = int(aa[3])
	xx = max(max(a, b), c)
	x = xx - a
	y = xx - b
	z = xx - c
	yy = x + y + z
	zz = dd - yy
	if (zz >= 0) & (zz % 3 == 0):
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	sum = 0
	p = list(map(int, input().strip().split()))
	sum = p[0] + p[1] + p[2] + p[3]
	if sum % 3 != 0 or sum / 3 < p[0] or sum / 3 < p[1] or (sum / 3 < p[2]):
		print('No')
	else:
		print('Yes')


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


t = int(input())
cou = []
for i in range(t):
	(a, b, c, n) = map(int, input().split())
	x = max(a, b, c)
	if c == x:
		y = c + c - a - b
		if (n - y) % 3 == 0 and n - y >= 0:
			cou.append('YES')
		else:
			cou.append('NO')
	elif b == x:
		y = b + b - a - c
		if (n - y) % 3 == 0 and n - y >= 0:
			cou.append('YES')
		else:
			cou.append('NO')
	else:
		y = a + a - c - b
		if (n - y) % 3 == 0 and n - y >= 0:
			cou.append('YES')
		else:
			cou.append('NO')
for i in range(t):
	print(cou[i])


t = int(input())
for _ in range(t):
	(a, b, c, n) = map(int, input().split())
	m = max(a, b, c)
	to = m - a + m - b + m - c
	if to > n:
		print('NO')
		continue
	if (n - to) % 3 == 0:
		print('YES')
		continue
	print('NO')


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


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


a = int(input())
for i in range(a):
	p = list(map(int, input().split()))
	z = p[-1]
	p.remove(z)
	p.sort(reverse=True)
	x = p[0] - p[1] + (p[0] - p[2])
	if z >= x and (z - x) % 3 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for case in range(t):
	(a, b, c, n) = map(int, input().split(' '))
	d = max(a, b, c)
	g = n - (d - a) - (d - b) - (d - c)
	if g >= 0 and g % 3 == 0:
		print('YES')
	else:
		print('NO')


count = int(input())
for item in range(count):
	mass = list(map(int, input().split()))
	sum_mass = sum(mass)
	is_check = False
	if sum_mass % 3 == 0:
		coin = sum_mass // 3
		for i in mass[:-1]:
			if i > coin:
				is_check = True
				print('NO')
				break
		if not is_check:
			print('YES')
	else:
		print('NO')


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


n = int(input())
while n:
	(a, b, c, x) = map(int, input().split())
	op = max(a, b, c) - a + (max(a, b, c) - b) + (max(a, b, c) - c)
	x = x - op
	if x < 0 or x % 3 != 0:
		print('NO')
	else:
		print('YES')
	n = n - 1


for _ in range(int(input())):
	(a, b, c, n) = list(map(int, input().split()))
	l = max(a, b, c)
	k = n - (l - a) - (l - b) - (l - c)
	if k >= 0 and k % 3 == 0:
		print('Yes')
	else:
		print('No')


t = int(input())
for _ in range(t):
	(a, b, c, n) = map(int, input().split())
	s = a + b + c
	res = (s + n) // 3
	tr = True
	for i in [a, b, c]:
		if i <= res:
			continue
		else:
			tr = False
	if res * 3 == s + n and tr:
		print('YES')
	else:
		print('NO')


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


test = int(input())
while test > 0:
	l = list(map(int, input().split()))
	x = l[0]
	y = l[1]
	z = l[2]
	n = l[3]
	s = x + y + z + n
	if s % 3 == 0 and x <= s / 3 and (y <= s / 3) and (z <= s / 3):
		print('YES')
	else:
		print('NO')
	test = test - 1


def arr_inp(n):
	if n == 1:
		return [int(x) for x in stdin.readline().split()]
	elif n == 2:
		return [float(x) for x in stdin.readline().split()]
	else:
		return [str(x) for x in stdin.readline().split()]
from sys import stdin
for i in range(int(input())):
	(a, b, c, n) = arr_inp(1)
	ar = sorted([a, b, c])
	(extra1, extra2) = (ar[-1] - ar[0], ar[-1] - ar[1])
	all = n - (extra2 + extra1)
	print('NO' if all % 3 or all < 0 else 'YES')


mod = 1000000007
from math import factorial, ceil, pow, sqrt, floor
from sys import stdin, stdout
from collections import defaultdict, Counter, deque
for _ in range(int(stdin.readline())):
	(a, b, c, n) = map(int, stdin.readline().split())
	d = max(a, b, c)
	d = 3 * d - (a + b + c)
	if d > n:
		print('NO')
	elif (n - d) % 3 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	d = list(map(int, input().split()))
	s = max(d[:3])
	v = sum(d)
	if v % 3 == 0 and v // 3 >= s:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(a, b, c, n) = map(int, input().split())
	hmax = max(a, max(b, c))
	total = a + b + c + n
	if total % 3 == 0 and total // 3 >= hmax:
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	L = [int(i) for i in input().split()]
	n = L[3]
	del L[3]
	L.sort()
	for i in range(3):
		x = max(L) - L[i]
		L[i] += x
		n -= x
	if n >= 0 and n % 3 == 0:
		print('YES')
	else:
		print('NO')


testcases = [[int(x) for x in str(input()).split(' ')] for test in range(int(input()))]
for test in testcases:
	if test[0] == test[1] == test[2] and test[3] % 3 == 0:
		print('YES')
	elif test[0] == test[1] == test[2] and test[3] % 3 != 0:
		print('NO')
	if test[0] != test[1] or test[0] != test[2] or test[1] != test[2]:
		if test.index(max(test[:3])) == 0:
			if (test[3] - (test[0] - test[1]) - (test[0] - test[2])) % 3 == 0 and test[3] - (test[0] - test[1]) - (test[0] - test[2]) >= 0:
				print('YES')
			else:
				print('NO')
		if test.index(max(test[:3])) == 1:
			if (test[3] - (test[1] - test[0]) - (test[1] - test[2])) % 3 == 0 and test[3] - (test[1] - test[0]) - (test[1] - test[2]) >= 0:
				print('YES')
			else:
				print('NO')
		if test.index(max(test[:3])) == 2:
			if (test[3] - (test[2] - test[0]) - (test[2] - test[1])) % 3 == 0 and test[3] - (test[2] - test[0]) - (test[2] - test[1]) >= 0:
				print('YES')
			else:
				print('NO')


def main():
	t = int(input())
	outputs = []
	for i in range(t):
		(a, b, c, n) = [int(x) for x in input().split()]
		inputs = [a, b, c]
		inputs = sorted(inputs)
		n -= 2 * inputs[2] - inputs[1] - inputs[0]
		if n < 0 or n % 3 != 0:
			outputs.append('NO')
		else:
			outputs.append('YES')
	for x in outputs:
		print(x)
main()


t = int(input())
for i in range(0, t):
	abcn = [int(x) for x in input().split()]
	m = abcn[:3]
	m = max(m)
	total = 0
	for ii in range(0, 3):
		total = total + (m - abcn[ii])
	if total > abcn[3]:
		print('NO')
	else:
		abcn[3] = (abcn[3] - total) % 3
		if abcn[3] == 0:
			print('YES')
		else:
			print('NO')


for _ in range(int(input())):
	(a, b, c, n) = map(int, input().split())
	s = a + b + c + n
	if s % 3 != 0:
		print('NO')
		continue
	s //= 3
	if max(a, b, c) > s:
		print('NO')
		continue
	print('YES')


def compute_naive(a, b, c, n):
	if a == b == c:
		return True
	A = 0
	B = 0
	C = 0
	for j in range(0, n + 1):
		A = j
		m = n - j
		for k in range(0, m + 1):
			B = k
			C = m - k
			if A + a == B + b == C + c or A + a == C + b == B + c or B + a == A + b == C + c or (B + a == C + b == A + c) or (C + a == A + b == B + c) or (C + a == B + b == A + c):
				return True
	return False

def compute_net(a, b, c, n):
	k = n + a + c - 2 * b
	if k % 3 == 0 and k / 3 >= 0 and (b - a + k / 3 >= 0) and (b - c + k / 3 >= 0):
		return True
	else:
		return False

def compute(a, b, c, n):
	if (a + b + c + n) % 3 != 0:
		return False
	if max(a, b, c) > (a + b + c + n) / 3:
		return False
	return True

def main():
	t = int(input().split()[0])
	for i in range(0, t):
		(a, b, c, n) = map(int, input().split())
		cond = compute_net(a, b, c, n)
		if cond:
			print('YES')
		else:
			print('NO')
main()


def solve():
	t = int(input())
	for i in range(t):
		(a, b, c, n) = [int(s) for s in input().split()]
		max_m = max(a, b, c)
		s = max_m - a + max_m - b + max_m - c
		if s <= n:
			if (n - s) % 3 == 0:
				print('YES')
			else:
				print('NO')
		else:
			print('NO')
solve()


def are_enough_coins_left(num_coins):
	if num_coins < 0:
		return False
	else:
		return True

def are_enough_coins_to_share(num_coins):
	if num_coins % 3 == 0:
		return True
	else:
		return False

def evaluate_conditions(enough_coins_left, enough_coins_to_share):
	if enough_coins_left & enough_coins_to_share:
		print('YES')
	else:
		print('NO')
num_tests = int(input())
for test_num in range(0, num_tests):
	test_case = input()
	if test_case:
		coins = [int(x) for x in test_case.split()]
		coins_left = coins.pop(3)
		sisters_coins = coins
		enough_coins = True
		if not max(sisters_coins) == min(sisters_coins):
			for sister_coins in sisters_coins:
				coins_left -= max(sisters_coins) - sister_coins
				enough_coins = are_enough_coins_left(coins_left)
				if not enough_coins:
					break
		evaluate_conditions(enough_coins, are_enough_coins_to_share(coins_left))
	else:
		break


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


for e in range(int(input())):
	(a, b, c, n) = map(int, input().split())
	m = max(a, b, c)
	for i in [a, b, c]:
		if n < 0:
			print('NO')
			break
		else:
			n = n - (m - i)
	else:
		if n % 3 == 0 and n >= 0:
			print('YES')
		else:
			print('NO')


t = int(input())
while t > 0:
	t = t - 1
	a = [int(x) for x in input().split()]
	n = a.pop()
	d = max(a)
	for i in a:
		n = n - (d - i)
	if n < 0 or n % 3 != 0:
		print('NO')
	else:
		print('YES')


test = int(input())
while test:
	test = test - 1
	(a, b, c, n) = [int(x) for x in input().split()]
	x = [a, b, c]
	q = max(x)
	x = 3 * q - sum(x)
	if (n - x) % 3 == 0 and n - x >= 0:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(a, b, c, n) = map(int, input().split())
	s = sum([a, b, c, n])
	if s % 3 or any(map(lambda x: x > s // 3, [a, b, c])):
		print('NO')
	else:
		print('YES')


T = int(input())
for _ in range(T):
	(a, b, c, n) = map(int, input().split())
	max_coin = max(a, b, c)
	gap = 0
	for p in [a, b, c]:
		gap += max_coin - p
	if gap > n:
		print('NO')
	elif (n - gap) % 3 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(a, b, c, n) = map(int, input().split())
	ar = [a, b, c]
	ar.sort()
	st = ar[2] - ar[0] + (ar[2] - ar[1])
	n -= st
	if n >= 0 and n % 3 == 0:
		print('YES')
	else:
		print('NO')


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


def possibleCoins(string):
	process = string.split()
	for i in range(0, len(process)):
		process[i] = int(process[i])
	a = process[0]
	b = process[1]
	c = process[2]
	n = process[3]
	maxNumForEqual = max(a, b, c)
	diffForEqual = maxNumForEqual - a + (maxNumForEqual - b) + (maxNumForEqual - c)
	if diffForEqual > n:
		return False
	else:
		n -= diffForEqual
		if n // 3 == n / 3:
			return True
		return False
numOfTests = int(input())
currentStr = ''
temp = False
for i in range(0, numOfTests):
	currentStr = input()
	temp = possibleCoins(currentStr)
	if temp:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(a, b, c, n) = map(int, input().split())
	k = max(a, b, c)
	sum = k - a + (k - b) + (k - c)
	rem = n - sum
	if n >= sum and rem % 3 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
while t != 0:
	t -= 1
	(a, b, c, n) = map(int, input().split())
	coin_list = list()
	coin_list.append(a)
	coin_list.append(b)
	coin_list.append(c)
	max_v = max(coin_list)
	a1 = max_v - a
	b1 = max_v - b
	c1 = max_v - c
	sumofcoin = a1 + b1 + c1
	if sumofcoin > n:
		print('NO')
	elif sumofcoin == n:
		print('YES')
	elif sumofcoin < n:
		n1 = n - sumofcoin
		if n1 % 3 == 0:
			print('YES')
		else:
			print('NO')


for i in range(int(input())):
	a = list(map(int, input().split()))
	s = sum(a)
	print('YNEOS'[s % -3 | s - 3 * max(a[:3]) < 0::2])


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


s = []
T = int(input())
for t in range(T):
	(a, b, c, n) = map(int, input().split())
	if max(a, b, c) == a and min(a, b, c) == b:
		if n >= a - b:
			n -= a - b
			b = a
		if n >= a - c:
			n -= a - c
			c = a
	elif max(a, b, c) == b and min(a, b, c) == a:
		if n >= b - a:
			n -= b - a
			a = b
		if n >= b - c:
			n -= b - c
			c = b
	elif max(a, b, c) == a and min(a, b, c) == c:
		if n >= a - b:
			n -= a - b
			b = a
		if n >= a - c:
			n -= a - c
			c = a
	elif max(a, b, c) == c and min(a, b, c) == a:
		if n >= c - b:
			n -= c - b
			b = c
		if n >= c - a:
			n -= c - a
			a = c
	elif max(a, b, c) == b and min(a, b, c) == c:
		if n >= b - a:
			n -= b - a
			a = b
		if n >= b - c:
			n -= b - c
			c = b
	elif max(a, b, c) == c and min(a, b, c) == b:
		if n >= c - b:
			n -= c - b
			b = c
		if n >= c - a:
			n -= c - a
			a = c
	if a == b == c and n >= 0:
		if n % 3 == 0:
			s.append('YES')
		else:
			s.append('NO')
	else:
		s.append('NO')
for i in s:
	print(i)


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


n = int(input())
for i in range(n):
	a = [int(x) for x in input().split()]
	total = sum(a)
	if total % 3 != 0:
		print('NO')
		continue
	e = total / 3
	decided = False
	for j in range(3):
		if a[j] > e:
			print('NO')
			decided = True
			break
	if not decided:
		print('YES')


from bisect import *
from collections import *
from itertools import *
import functools
import sys
import math
from decimal import *
from copy import *
from heapq import *
from fractions import *
getcontext().prec = 30
MAX = sys.maxsize
MAXN = 10 ** 5 + 10
MOD = 10 ** 9 + 7
spf = [i for i in range(MAXN)]
spf[0] = spf[1] = -1

def sieve():
	for i in range(2, MAXN, 2):
		spf[i] = 2
	for i in range(3, int(MAXN ** 0.5) + 1):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def fib(n, m):
	if n == 0:
		return [0, 1]
	else:
		(a, b) = fib(n // 2)
		c = a % m * (b % m * 2 - a % m) % m
		d = a % m * (a % m) % m + b % m * b % m % m
		if n % 2 == 0:
			return [c, d]
		else:
			return [d, c + d]

def charIN(x=' '):
	return sys.stdin.readline().strip().split(x)

def arrIN(x=' '):
	return list(map(int, sys.stdin.readline().strip().split(x)))

def ncr(n, r):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % MOD
		den = den * (i + 1) % MOD
	return num * pow(den, MOD - 2, MOD) % MOD

def flush():
	return sys.stdout.flush()
for _ in range(int(input())):
	(a, b, c, n) = arrIN()
	mx = max(a, b, c)
	n -= mx - a
	n -= mx - b
	n -= mx - c
	if n < 0 or n % 3:
		print('No')
	else:
		print('Yes')


for i in range(int(input())):
	l = list(map(int, input().split()))
	if sum(l) % 3 == 0:
		p = sum(l) // 3
		if l[0] > p or l[1] > p or l[2] > p:
			print('NO')
		else:
			print('YES')
	else:
		print('NO')


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


t = int(input())
for i in range(t):
	(a, b, c, n) = [int(a) for a in input().split()]
	x = max(a, b, c)
	m = x - a + (x - b) + (x - c)
	y = n - m
	if y < 0 or y % 3 != 0:
		print('NO')
	else:
		print('YES')


def main():
	t = int(input())
	while t > 0:
		ci = list(map(int, input().split()))
		n = ci.pop()
		ci.sort()
		(a, b, c) = ci
		d = c - b
		e = c - a
		n = n - d - e
		if n > 0:
			if n % 3 == 0:
				print('YES')
			else:
				print('NO')
		elif n == 0:
			print('YES')
		else:
			print('NO')
		t -= 1
main()


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


q = int(input())
for j in range(q):
	(a, b, c, n) = list(map(int, input().split(' ')))
	if a == b and b == c:
		if n % 3 == 0:
			print('YES')
		else:
			print('NO')
	else:
		d = max(a, b)
		e = max(b, c)
		g = max(d, e)
		abc = g - a + g - b + g - c
		n1 = n - abc
		if abc > n:
			print('NO')
		elif n1 % 3 == 0:
			print('YES')
		else:
			print('NO')


for _ in range(int(input())):
	a = list(map(int, input().split()))
	r = sum(a)
	n = r // 3
	print('YES' if r % 3 == 0 and max(a[:len(a) - 1]) <= n else 'NO')


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


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


t = int(input())
answers = []
for ti in range(t):
	ints = list(map(int, input().split()))
	(a, b, c, n) = (ints[0], ints[1], ints[2], ints[3])
	_max = max(a, b, c)
	diff = _max - a + (_max - b) + (_max - c)
	if diff > n:
		answers.append('NO')
		continue
	n = n - diff
	if n % 3 == 0:
		answers.append('YES')
	else:
		answers.append('NO')
for a in answers:
	print(a)


t = int(input())
for i in range(t):
	(a, b, c, n) = map(int, input().strip().split())
	k = int((a + b + c + n) / 3)
	x = k - a
	y = k - b
	z = k - c
	if x < 0:
		x = 0
	if y < 0:
		y = 0
	if z < 0:
		z = 0
	if (a + b + c + n) % 3 == 0 and x + a == y + b and (y + b == z + c) and (z + c == x + a):
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	a = input().split(' ')
	n = int(a.pop())
	a = [int(i) for i in a]
	maxa = max(a)
	b = [abs(i - maxa) for i in a]
	h = n - sum(b)
	if h >= 0 and h % 3 == 0:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(a, b, c, d) = map(int, input().split())
	Z = max(a, b, c)
	S = Z - a + (Z - b) + (Z - c)
	if d - S < 0:
		print('NO')
	elif d - S == 0:
		print('YES')
	elif (d - S) % 3 == 0:
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	arr = [int(i) for i in input().split()]
	sumArr = sum(arr)
	if sumArr % 3 == 0 and arr[0] <= sumArr // 3 and (arr[1] <= sumArr // 3) and (arr[2] <= sumArr // 3):
		print('YES')
	else:
		print('NO')


def solve(a, b, c, n):
	return sum((max(a, b, c) - x for x in (a, b, c))) <= n and sum((a, b, c, n)) % 3 == 0
for T in range(int(input())):
	print('YES' if solve(*map(int, input().split())) else 'NO')


t = int(input())
for _ in range(t):
	ls = [int(x) for x in input().split()]
	tot = ls[0] + ls[1] + ls[2] + ls[3]
	if tot % 3 == 0 and (tot / 3 >= ls[0] and tot / 3 >= ls[1] and (tot / 3 >= ls[2])):
		print('YES')
	else:
		print('NO')


q = int(input())
for ccccccccccc in range(q):
	(a, b, c, n) = map(int, input().split())
	g = a + b + c + n
	if g % 3 == 0:
		if max(a, b, c) - min(a, b, c) + (max(a, b, c) - (a + b + c - min(a, b, c) - max(a, b, c))) <= n:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


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


import math
import sys
from sys import *
from bisect import insort
import heapq
import collections
from collections import deque, defaultdict
from itertools import permutations, combinations, combinations_with_replacement
import random
import os
mod = 10 ** 9 + 7
MAX = sys.maxsize
MIN = -sys.maxsize - 1

def isPrime(n):
	if n > 1:
		for i in range(2, n):
			if n % i == 0:
				return False
		else:
			return True
	else:
		return False

def isPanagram(s):
	alphabet = 'abcdefghijklmnopqrstuvwxyz'
	for char in alphabet:
		if char not in s.lower():
			return False
	return True

def isEqual(list1):
	if len(list1) < 0:
		res = True
	res = all((ele == list1[0] for ele in list1))
	if res:
		return True
	else:
		return False

def remove_duplicate(list1):
	final_list = []
	for i in list1:
		if i not in final_list:
			final_list.append(i)
	return final_list % mod

def solve():
	arr = list(map(int, input().split()))
	s = sum(arr)
	if s % 3 == 0 and s // 3 >= max(arr[0], arr[1], arr[2]):
		return 'YES'
	return 'NO'
t = int(stdin.readline())
for i in range(t):
	result = solve()
	stdout.write(str(result) + '\n')


T = int(input())
for x in range(T):
	(a, b, c, n) = map(int, input().split())
	s = max(a, max(b, c))
	diff = s - a + (s - b) + (s - c)
	n = n - diff
	if n < 0:
		print('NO')
	elif n % 3 != 0:
		print('NO')
	else:
		print('YES')


from sys import stdin, stdout
import math
from itertools import permutations, combinations
from collections import defaultdict

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

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

def I():
	return int(stdin.readline())
P = 1000000007
for t in range(I()):
	(a, b, c, n) = In()
	l = [a, b, c]
	l.sort()
	s = 2 * l[2] - (l[1] + l[0])
	if n - s >= 0 and (n - s) % 3 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
while t > 0:
	a = []
	a = list(map(int, input().split()))
	n = a[3]
	a.pop()
	a.sort()
	x = a[2] - a[0]
	y = a[2] - a[1]
	z = x + y
	res = n - z
	if res < 0:
		print('NO')
		t -= 1
		continue
	if res % 3 == 0:
		print('YES')
	else:
		print('NO')
	t -= 1
	if t < 0:
		break


t = int(input())
for q in range(t):
	a = [int(x) for x in input().split()]
	total = a[3]
	a = a[0:3]
	a.sort(reverse=True)
	diff1 = a[0] - a[2]
	diff2 = a[0] - a[1]
	total = total - diff1 - diff2
	if total % 3 == 0 and total >= 0:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(a, b, c, n) = [int(x) for x in input().split()]
	k = max(a, b, c)
	g = k - a + k - b + k - c
	if n >= g and (n - g) % 3 == 0:
		print('YES')
	else:
		print('NO')


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


for t in range(int(input())):
	(a, b, c, n) = list(map(int, input().split()))
	(x, z) = (max(a, b, c), min(a, b, c))
	y = a + b + c - (x + z)
	l = x - y + (x - z)
	n = n - l
	if n < 0 or n % 3 != 0:
		print('NO')
	else:
		print('YES')


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


x = int(input())
for i in range(x):
	(a, b, c, n) = map(int, input().split())
	f = max(a, b, c)
	if f == a:
		tb = a - b
		tc = a - c
		s = tc + tb
	elif f == b:
		ta = b - a
		tc = b - c
		s = ta + tc
	elif f == c:
		ta = c - a
		tb = c - b
		s = ta + tb
	if n - s < 0:
		print('NO')
		continue
	else:
		n -= s
	if n % 3 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	four = input().split()
	A = int(four[0])
	B = int(four[1])
	C = int(four[2])
	P = int(four[3])
	Flag = False
	M = max(A, B, C)
	m = min(A, B, C)
	E = A + B + C - M - m
	D = 2 * M - m - E
	if A == B == C or P >= D:
		R = P - D
		if R % 3 == 0:
			Flag = True
	if Flag == True:
		print('YES')
	else:
		print('NO')


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


import sys
import math
input = sys.stdin.readline
for _ in range(int(input())):
	(a, b, c, n) = list(map(int, input().split()))
	f = [a, b, c]
	f.sort()
	m = f[2] - f[0] + f[2] - f[1]
	if m > n:
		print('NO')
	else:
		n -= m
		if n % 3:
			print('NO')
		else:
			print('YES')


for _ in range(int(input())):
	(a, b, c, n) = list(map(int, input().split()))
	numArr = [a, b, c]
	maxNum = max(numArr)
	diff = 0
	for i in range(len(numArr)):
		diff -= maxNum - numArr[i]
	if abs(diff) > n:
		print('NO')
	elif (diff + n) % 3 == 0:
		print('YES')
	else:
		print('NO')


import copy
T = int(input())
for i in range(T):
	l = list(map(int, input().split()))
	maxe = max(l[:-1])
	mine = min(l[:-1])
	ll = copy.deepcopy(l[:-1])
	ll.remove(maxe)
	asd = []
	x = len(l[:-1])
	if mine == maxe:
		if l[-1] % x == 0:
			print('YES')
		else:
			print('NO')
	elif ll.count(maxe) > 0:
		t = ll.count(maxe)
		for i in range(t):
			ll.remove(maxe)
		for i in ll:
			asd.append(maxe - i)
		s = sum(asd)
		q = l[-1] - s
		if q < 0:
			print('NO')
		elif q % x == 0:
			print('YES')
		else:
			print('NO')
	else:
		for i in ll:
			asd.append(maxe - i)
		s = sum(asd)
		q = l[-1] - s
		if q < 0:
			print('NO')
		elif q % x == 0:
			print('YES')
		else:
			print('NO')


t = int(input())
while t > 0:
	t -= 1
	(a, b, c, n) = map(int, input().split())
	maxx = max(a, b, c)
	x = maxx - a
	y = maxx - b
	z = maxx - c
	q = n - (x + y + z)
	if q >= 0 and q % 3 == 0:
		print('YES')
	else:
		print('NO')


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


import sys
import math
from collections import defaultdict, Counter
t = int(input())
for i in range(t):
	(a, b, c, n) = map(int, input().split())
	m = max(a, b, c)
	s1 = abs(m - a) + abs(m - b) + abs(m - c)
	n -= s1
	if n % 3 == 0 and n >= 0:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(a, b, c, n) = map(int, input().split())
	ar = [a, b, c]
	ar.sort()
	z = ar[2] - ar[1] + ar[2] - ar[0]
	if z <= n:
		n = n - z
	else:
		print('NO')
		continue
	if n % 3 == 0:
		print('YES')
		continue
	else:
		print('NO')


for _ in range(int(input())):
	(a, b, c, n) = map(int, input().split())
	ar = [a, b, c]
	m = max(ar)
	n -= sum([m - e for e in ar])
	if n % 3 == 0 and n >= 0:
		print('YES')
	else:
		print('NO')


t = int(input())
while t > 0:
	num = [int(e) for e in input().split()]
	n = num[-1]
	num = sorted(num[:-1])
	atleast = 2 * num[2] - num[0] - num[1]
	if n >= atleast and (n - atleast) % 3 == 0:
		print('YES')
	else:
		print('NO')
	t -= 1


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


n = int(input())
l = [input().split() for i in range(n)]
ans = []
for i in range(n):
	if (int(l[i][0]) + int(l[i][1]) + int(l[i][2]) + int(l[i][3])) % 3 == 0 and int(l[i][0]) <= (int(l[i][0]) + int(l[i][1]) + int(l[i][2]) + int(l[i][3])) // 3 and (int(l[i][1]) <= (int(l[i][0]) + int(l[i][1]) + int(l[i][2]) + int(l[i][3])) // 3) and (int(l[i][2]) <= (int(l[i][0]) + int(l[i][1]) + int(l[i][2]) + int(l[i][3])) // 3):
		ans.append('YES')
	else:
		ans.append('NO')
print(*ans, sep='\n')


t = int(input())
for i in range(t):
	n = [int(x) for x in input().split()]
	a = n[0]
	b = n[1]
	c = n[2]
	d = n[3]
	m = max(a, b, c)
	ad = m - a
	bd = m - b
	cd = m - c
	if (d - ad - bd - cd) % 3 == 0 and d - ad - bd - cd >= 0:
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(0, n):
	(a, b, c, d) = [int(x) for x in input().split()]
	if (a + b + c + d) % 3 != 0:
		print('NO')
	else:
		mx = max(a, b, c)
		diff = 0
		diff += mx - a
		diff += mx - b
		diff += mx - c
		if diff <= d:
			print('YES')
		else:
			print('NO')


def f(x):
	a = 0
	while x != 0:
		a += x % 10
		x = x // 10
	return a
x = int(input())
for i in range(x):
	s = list(map(int, input().split(' ')))
	a = s[0]
	b = s[1]
	c = s[2]
	n = s[3]
	m = max(s[:-1])
	ans = n - (m - a + (m - b) + (m - c))
	if ans < 0:
		print('NO')
	elif f(ans) % 3 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for tt in range(t):
	(a, b, c, n) = map(int, input().split())
	mm = max(a, b, c)
	baaki = 3 * mm - a - b - c
	if baaki > n:
		print('NO')
	else:
		temp = n - baaki
		if temp % 3 == 0:
			print('YES')
		else:
			print('NO')


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


t = int(input())
for c in range(t):
	l = [int(i) for i in input().split()]
	n = l[3]
	l.pop(3)
	l.sort()
	maior = l[2]
	medio = l[1]
	menor = l[0]
	falta = maior - medio + (maior - menor)
	if falta > n:
		print('NO')
	else:
		n -= falta
		if n % 3 != 0:
			print('NO')
		else:
			print('YES')


t = int(input())
for i in range(0, t):
	q = list(map(int, input().split()))
	s = sum(q)
	m = max([q[0], q[1], q[2]])
	diff1 = abs(m - q[1])
	diff2 = abs(m - q[2])
	diff3 = abs(m - q[0])
	diff = diff1 + diff2 + diff3
	if s % 3 == 0 and diff <= q[3]:
		print('YES')
	else:
		print('NO')


def check():
	global a, b, c, n
	m = max(a, b, c)
	n -= 3 * m - (a + b + c)
	if n < 0:
		return False
	if n % 3 == 0:
		return True
	else:
		return False
for _ in range(int(input())):
	(a, b, c, n) = map(int, input().split(' '))
	if check():
		print('YES')
	else:
		print('NO')


for t in range(int(input())):
	(a, b, c, n) = [int(i) for i in input().split()]
	m = max(a, b, c)
	ans = 'NO'
	ost = n - (m - a + m - b + m - c)
	if ost >= 0 and ost % 3 == 0:
		ans = 'YES'
	print(ans)


for i in range(int(input())):
	a = list(map(int, input().split()))
	total = sum(a) % 3
	answer = sum(a) // 3
	if total == 0:
		temp1 = a[0] + abs(answer - a[0])
		temp2 = a[1] + abs(answer - a[1])
		temp3 = a[2] + abs(answer - a[2])
		if temp1 == temp2 == temp3:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


try:
	t = int(input())
	for h in range(t):
		l = list(map(int, input().split()))
		g = l[0] + l[1] + l[2] + l[3]
		if g % 3 == 0:
			a = int(g / 3)
			if l[0] <= a and l[1] <= a and (l[2] <= a):
				print('YES')
			else:
				print('NO')
		else:
			print('NO')
except Exception:
	pass


for x in range(int(input())):
	y = list(map(int, input().split()))
	if sum(y) % 3 == 0 and sum(y) / 3 >= max(y[0:3]):
		print('YES')
	else:
		print('NO')


x = int(input())
for i in range(0, x):
	(x1, x2, x3, x4) = input().split()
	x1 = int(x1)
	x2 = int(x2)
	x3 = int(x3)
	x4 = int(x4)
	l = []
	l.append(x1)
	l.append(x2)
	l.append(x3)
	l.sort()
	x4 -= l[2] - l[1]
	x4 -= l[2] - l[0]
	if x4 % 3 == 0 and x4 >= 0:
		print('YES')
	else:
		print('NO')


from sys import stdin as cin, stdout as cout
get = cin.readline
end = cout.flush

def put(x):
	cout.write(str(x))

def main():
	t = int(get())
	answer = []
	for i in range(t):
		(a, b, c, n) = list(map(int, get().split()))
		flag = True
		if (a + b + c + n) % 3 != 0:
			flag = False
			answer.append('NO')
		else:
			target = (a + b + c + n) // 3
			if target - a < 0 or target - b < 0 or target - c < 0:
				answer.append('NO')
			else:
				answer.append('YES')
	print(*answer, sep='\n')
main()


n = int(input())
ans = []
for i in range(n):
	(a, b, c, n) = map(int, input().split())
	while True:
		if n == 0 and a == b == c:
			ans.append('YES')
			break
		elif n > 0 and a == b == c:
			if n % 3 == 0:
				ans.append('YES')
				break
			else:
				ans.append('NO')
				break
		if n <= 0:
			ans.append('NO')
			break
		if a == min(a, b, c):
			k = max(a, b, c)
			n -= k - a
			a += k - a
		elif b == min(a, b, c):
			k = max(a, b, c)
			n -= k - b
			b += k - b
		elif c == min(a, b, c):
			k = max(a, b, c)
			n -= k - c
			c += k - c
for i in ans:
	print(i)


t = int(input())
for i in range(t):
	l = list(map(int, input().split()))
	n = l[3]
	l.remove(n)
	l.sort()
	d = l[2] - l[0]
	e = l[2] - l[1]
	f = n - d - e
	if f < 0 or f % 3 != 0:
		print('NO')
	else:
		print('YES')


t = input()
for i in range(0, int(t)):
	imp = input()
	a = int(imp.split(' ')[0])
	b = int(imp.split(' ')[1])
	c = int(imp.split(' ')[2])
	d = int(imp.split(' ')[3])
	tmp = a
	if b > tmp:
		tmp = b
	if c > tmp:
		tmp = c
	if (a + b + c + d) % 3 == 0 and a + b + c + d >= 3 * tmp:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(a, b, c, n) = map(int, input().split())
	e = (n + a + b + c) % 3
	d = (n + a + b + c) // 3
	if e == 0 and a <= d and (b <= d) and (c <= d):
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(a, b, c, n) = list(map(int, input().split()))
	a1 = (n + b + c - 2 * a) / 3
	b1 = (n + a + c - 2 * b) / 3
	c1 = (n + a + b - 2 * c) / 3
	res = a1 % 1 == 0 and b1 % 1 == 0 and (c1 % 1 == 0) and (a1 >= 0) and (b1 >= 0) and (c1 >= 0)
	print('YNEOS'[not res::2])


import sys
import os

def changeStdioToFile():
	path = os.path.dirname(os.path.abspath(__file__))
	sys.stdin = open(f'{path}/input.txt', 'r')
	sys.stdout = open(f'{path}/output.txt', 'w')
t = 1
t = int(input())
for _ in range(t):
	(a, b, c, n) = [int(x) for x in input().split()]
	x = (n + a + b + c) // 3
	y = (n + a + b + c) % 3
	if a > x or b > x or c > x or (y != 0):
		print('NO')
	else:
		print('YES')


v = input()
t = int(v)
while t > 0:
	t -= 1
	(a1, b1, c1, n1) = input().split()
	(a, b, c, n) = (int(a1), int(b1), int(c1), int(n1))
	val = n + (a + b + c)
	if val % 3 == 0 and val / 3 >= a and (val / 3 >= b) and (val / 3 >= c):
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(a, b, c, n) = map(int, input().split())
	maxx = max(a, b, c)
	t = maxx - a + (maxx - b) + (maxx - c)
	if t > n:
		print('NO')
	else:
		rem = n - t
		if rem % 3 == 0:
			print('YES')
		else:
			print('NO')


x = int(input())
for i in range(x):
	(a, b, c, n) = [int(x) for x in input().split()]
	coins = [a, b, c]
	coins.sort()
	minneeded = coins[2] - coins[1] + (coins[2] - coins[0])
	if n < minneeded:
		print('NO')
	elif (n - minneeded) % 3 == 0:
		print('YES')
	else:
		print('NO')


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


t = int(input())
lines = []
for i in range(int(t)):
	lines.append(input().split())
for i in range(t):
	line = lines[i]
	a = int(line[0])
	b = int(line[1])
	c = int(line[2])
	n = int(line[3])

	def grandezza():
		a_2 = max(a, b, c) - a
		b_2 = max(a, b, c) - b
		c_2 = max(a, b, c) - c
		if a_2 + b_2 + c_2 <= n:
			return True
		else:
			return False

	def divisibilita():
		a_2 = max(a, b, c) - a
		b_2 = max(a, b, c) - b
		c_2 = max(a, b, c) - c
		if (a_2 + b_2 + c_2 - n) % 3 == 0:
			return True
		else:
			return False
	if grandezza() and divisibilita():
		print('YES')
	else:
		print('NO')


import math
from bisect import bisect_left, bisect_right
from sys import stdin, stdout
input = lambda : stdin.readline().strip()
print = lambda s: stdout.write(s)
t = int(input())
for i in range(t):
	(a, b, c, n) = map(int, input().split())
	m = min(a, b, c)
	if not (a + b + c + n) % 3:
		if (a + b + c + n) // 3 < a or (a + b + c + n) // 3 < b or (a + b + c + n) // 3 < c:
			print('NO\n')
		else:
			print('YES\n')
	else:
		print('NO\n')


t = int(input())
for i in range(t):
	A = list(map(int, input().split()))
	a = A[0]
	b = A[1]
	c = A[2]
	n = A[3]
	temp = (a + b + c + n) // 3
	if (a + b + c + n) % 3 == 0 and max(a, b, c) <= temp:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	split_list = list(input().split())
	a = int(split_list[0])
	b = int(split_list[1])
	c = int(split_list[2])
	n = int(split_list[3])
	total_coins = a + b + c + n
	if total_coins % 3 != 0:
		print('NO')
	elif total_coins / 3 < a or total_coins / 3 < b or total_coins / 3 < c:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	(a, b, c, n) = list((int(i) for i in input().split()))
	A = []
	A.append(a)
	A.append(b)
	A.append(c)
	A.sort()
	p = n - (A[2] - A[0] + (A[2] - A[1]))
	if p % 3 == 0 and p >= 0:
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	k = list(map(int, input().split()))
	s = sum(k)
	li = []
	for i in range(len(k) - 1):
		li.append(k[i])
	t = max(li)
	if s % 3 == 0 and s // 3 >= t:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	l = list(map(int, input().split()))
	s = sum(l)
	x = s % 3
	b = max(l[1], l[2], l[0])
	if x == 0 and s // 3 >= b:
		print('YES')
	else:
		print('NO')


t = int(input())
arr = [[int(j) for j in input().split()] for i in range(t)]
for i in range(t):
	agrre = sum(arr[i]) / 3
	if arr[i][0] > agrre or arr[i][1] > agrre or arr[i][2] > agrre:
		print('NO')
		continue
	print('YES' if sum(arr[i]) % 3 == 0 else 'NO')


for _ in range(int(input())):
	(a, b, c, n) = map(int, input().split())
	(a, b, c) = sorted([a, b, c])
	d = b - a
	n -= d
	a += d
	d = c - b
	n -= 2 * d
	b += d
	res = n >= 0
	res &= n % 3 == 0
	print(['NO', 'YES'][res])


import math
t = int(input())
for i in range(t):
	(a, b, c, n) = map(int, input().split())
	x = a + b + c + n
	y = x // 3
	if x % 3 == 0 and a <= y and (b <= y) and (c <= y):
		print('YES')
	else:
		print('NO')


n = int(input())
a = []
for i in range(n):
	b = list(map(int, input().split()))
	g = b[0] + b[1] + b[2] - (max(b[0], b[1], b[2]) - b[0] + (max(b[0], b[1], b[2]) - b[1]) + (max(b[0], b[1], b[2]) - b[2])) - b[3]
	c = max(b[0], b[1], b[2]) - b[0] + (max(b[0], b[1], b[2]) - b[1]) + (max(b[0], b[1], b[2]) - b[2])
	if b[3] < c:
		a.append('NO')
	elif g % 3 == 0:
		a.append('YES')
	elif g == 0:
		a.append('Yes')
	else:
		a.append('NO')
for i in a:
	print(i)


for _ in range(int(input())):
	(a, b, c, n) = map(int, input().split())
	x = max(a, b)
	m = max(x, c)
	q = m - a
	w = m - b
	e = m - c
	if q >= 0:
		n = n - q
	if w >= 0:
		n = n - w
	if e >= 0:
		n = n - e
	if n >= 0 and n % 3 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
list1 = []
for _ in range(t):
	Z = list(map(int, input().split()))
	(a, b, c, n) = (Z[0], Z[1], Z[2], Z[3])
	maximum = max([a, b, c])
	diff1 = abs(maximum - a)
	diff2 = abs(maximum - b)
	diff3 = abs(maximum - c)
	diff = diff1 + diff2 + diff3
	if (a + b + c + n) % 3 == 0 and diff <= n:
		list1.append('YES')
	else:
		list1.append('NO')
for i in list1:
	print(i)


def collect():
	(a, b, c, d) = input().split()
	d = int(d)
	coins = [0, 0, 0]
	coins[0] = int(a)
	coins[1] = int(b)
	coins[2] = int(c)
	coins.sort()
	subs = coins[2] - coins[1] + coins[2] - coins[0]
	if d < subs:
		print('NO')
	elif (d - subs) % 3 == 0:
		print('YES')
	else:
		print('NO')
n = input()
n = int(n)
for i in range(n):
	collect()


q = int(input())
for _ in range(q):
	(a, b, c, n) = map(int, input().split())
	m = max(a, b, c)
	s = a + b + c
	req = 3 * m - s
	rest = n - req
	if req > n:
		print('NO')
	elif rest % 3 == 0:
		print('YES')
	else:
		print('NO')


test = int(input())
while test:
	(a, b, c, n) = map(int, input().split())
	total = 0
	while True:
		if a == b == c and n % 3 == 0:
			print('YES')
			break
		elif n == 0:
			print('NO')
			break
		elif a == b == c and n % 3 != 0:
			print('NO')
			break
		else:
			m = max(a, b, c)
			if m == a:
				if a - b + (a - c) <= n:
					n -= a - b
					n -= a - c
					b += a - b
					c += a - c
				else:
					print('NO')
					break
			elif m == b:
				if b - a + (b - c) <= n:
					n -= b - a
					n -= b - c
					a += b - a
					c += b - c
				else:
					print('NO')
					break
			elif c - a + (c - b) <= n:
				n -= c - a
				n -= c - b
				a += c - a
				b += c - b
			else:
				print('NO')
				break
	test -= 1


print(*((lambda a, b, c, n: 'YES' if (a + b + c + n) % 3 == 0 and max(a, b, c) <= (a + b + c + n) // 3 else 'NO')(*map(int, input().split())) for test in range(int(input()))), sep='\n')


t = int(input())
for _ in range(t):
	l = list(map(int, input().split()))
	n = l.pop()
	l.sort()
	(a, b, c) = l
	if n > 2 * c - b - a:
		x = 2 * c - b - a
		if (n - x) % 3 == 0:
			print('YES')
		else:
			print('NO')
	elif n == 2 * c - b - a:
		print('YES')
	else:
		print('NO')


t = int(input())
while t > 0:
	(a, b, c, n) = input().split()
	a = int(a)
	b = int(b)
	c = int(c)
	n = int(n)
	s = a + b + c + n
	x = s // 3
	if s % 3 == 0 and a <= x and (b <= x) and (c <= x):
		print('YES')
	else:
		print('NO')
	t -= 1


def main():
	t = int(input())
	for i in range(t):
		(a, b, c, n) = [int(j) for j in input().split()]
		li = []
		li.append(a)
		li.append(b)
		li.append(c)
		li.sort(reverse=True)
		if n - (abs(li[0] - li[1]) + abs(li[0] - li[2])) < 0:
			print('NO')
		elif (n - (abs(li[0] - li[1]) + abs(li[0] - li[2]))) % 3 == 0:
			print('YES')
		else:
			print('NO')
main()


import itertools
import math
import sys
import heapq
from collections import Counter
from collections import deque
from fractions import gcd
from functools import reduce
sys.setrecursionlimit(4100000)
INF = 1 << 60
t = int(input())
for i in range(t):
	(a, b, c, n) = map(int, input().split())
	x = sorted([a, b, c])
	if n - (x[2] - x[0] + x[2] - x[1]) < 0:
		print('NO')
	elif (n - (x[2] - x[0] + x[2] - x[1])) % 3 == 0:
		print('YES')
	else:
		print('NO')


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


testcase = int(input())
for _ in range(testcase):
	(a, b, c, n) = [int(i) for i in input().split()]
	if a >= b:
		if a >= c:
			max_n = a
			diff = 2 * a - (b + c)
		else:
			max_n = c
			diff = 2 * c - (a + b)
	elif b >= c:
		max_n = b
		diff = 2 * b - (a + c)
	else:
		max_n = c
		diff = 2 * c - (a + b)
	if n >= diff:
		remains = n - diff
		if remains % 3 == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


test = int(input())
while test > 0:
	str = input().split()
	a = int(str[0])
	b = int(str[1])
	c = int(str[2])
	d = int(str[3])
	m = max(a, b, c)
	sum = m - a + (m - b) + (m - c)
	if d - sum >= 0 and (d - sum) % 3 == 0:
		print('Yes')
	else:
		print('No')
	test = test - 1


t = input()
t = int(t)
for i in range(t):
	q = input().split()
	n = int(q.pop())
	q = [int(x) for x in q]
	q.sort()
	alpha = n - (q[2] - q[0] + (q[2] - q[1]))
	if alpha % 3 == 0 and alpha >= 0:
		print('YES')
	else:
		print('NO')


import sys
T = int(sys.stdin.readline())
for i in range(T):
	(a, b, c, n) = map(int, sys.stdin.readline().split())
	big = max(a, b, c)
	if (a + b + c + n - 3 * big) % 3 == 0 and a + b + c + n - 3 * big >= 0:
		print('YES')
	else:
		print('NO')


def coins(a, b, c, n):
	mx = max(a, b, c)
	res = n - (3 * mx - a - b - c)
	if res % 3 == 0 and res >= 0:
		print('YES')
	else:
		print('NO')
t = int(input())
for _ in range(t):
	(a, b, c, n) = map(int, input().split())
	coins(a, b, c, n)


t = int(input())
lines = []
for i in range(t):
	lines.append(input().split())

def is_possible(a, b, c, n):
	if not (a + b + c + n) % 3 == 0:
		return False
	children = sorted([a, b, c])
	if children[2] - children[1] + (children[2] - children[0]) > n:
		return False
	return True
for i in range(t):
	line = lines[i]
	a = int(line[0])
	b = int(line[1])
	c = int(line[2])
	n = int(line[3])
	if is_possible(a, b, c, n):
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(a, b, c, n) = map(int, input().split())
	sm = a + b + c + n
	slot = sm // 3
	if sm % 3 == 0 and (a <= slot and b <= slot and (c <= slot)):
		a1 = slot - a
		b1 = slot - b
		c1 = slot - c
		a += a1
		b += b1
		c += c1
		if a + b + c == sm:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


t = int(input())

def check(a, b, c, n):
	m = max(a, max(b, c))
	e = abs(m - a) + abs(m - b) + abs(m - c)
	if e <= n:
		if (n - e) % 3 == 0:
			return 'YES'
	return 'NO'
for _ in range(t):
	(a, b, c, n) = input().split(' ')
	(a, b, c, n) = (int(a), int(b), int(c), int(n))
	print(check(a, b, c, n))


for i in range(int(input())):
	(a, b, c, n) = map(int, input().split())
	result = sum([a, b, c, n])
	print('YES' if result % 3 == 0 and all([result // 3 >= j for j in [a, b, c]]) else 'NO')


t = int(input())
for i in range(t):
	(a, b, c, n) = map(int, input().split())
	s = a + b + c
	if (s + n) % 3:
		print('NO')
	else:
		res = (s + n) / 3
		if a > res or b > res or c > res:
			print('NO')
		else:
			print('YES')


t = int(input())
for _ in range(t):
	(a, b, c, n) = map(int, input().split())
	m = max(a, b, c)
	m = 3 * m - (a + b + c)
	if n < m:
		print('No')
	elif (n - m) % 3 == 0:
		print('Yes')
	else:
		print('No')


t = int(input())
ans = list()
for i in range(t):
	(a, b, c, n) = map(int, input().split())
	d = [a, b, c]
	d.sort()
	if d[2] - d[0] + d[2] - d[1] > n:
		ans.append('NO')
	else:
		n -= d[2] - d[0]
		n -= d[2] - d[1]
		if n % 3 != 0:
			ans.append('NO')
		else:
			ans.append('YES')
print(*ans, sep='\n')


t = int(input())
max = 0
g1 = 0
g2 = 0
new = 0
b = 0
for m in range(t):
	x = input().split()
	x = [int(x[i]) for i in range(len(x))]
	b = x[3]
	x.pop()
	x.sort()
	if x[2] * 2 - x[0] - x[1] > b:
		print('NO')
	else:
		g1 = x[2] - x[1]
		g2 = x[2] - x[0]
		new = b - (g1 + g2)
		if new % 3 == 0:
			print('YES')
		else:
			print('NO')


case_num = int(input())
i = 1
while i <= case_num:
	(a, b, c, n) = list(map(int, input().split()))
	coins_of = sorted([a, b, c])
	rem = n - (coins_of[2] - coins_of[1] + coins_of[2] - coins_of[0])
	if rem < 0:
		print('NO')
	elif rem == 0:
		print('YES')
	elif int(rem % 3) == 0:
		print('YES')
	else:
		print('NO')
	i += 1


t = int(input())
answers = []
for i in range(t):
	(a, b, c, n) = input().split()
	(a, b, c) = (int(a), int(b), int(c))
	lst = [a, b, c]
	n = int(n)
	max_c = max(a, b, c)
	min_c = min(a, b, c)
	lst.remove(max_c)
	lst.remove(min_c)
	mid_c = lst[0]
	n = n - (max_c - mid_c)
	n = n - (max_c - min_c)
	if n % 3 == 0 and n >= 0:
		answers.append('YES')
	else:
		answers.append('NO')
for i in answers:
	print(i)


while True:
	n = int(input(''))
	if 1 <= n <= 10 ** 4:
		break
d = []
for i in range(n):
	while True:
		x = input('')
		l = x.split(' ')
		if len(l) == 4:
			for i in range(4):
				l[i] = int(l[i])
			if 0 <= int(l[0]) <= 10 ** 8 and 0 <= int(l[1]) <= 10 ** 8 and (0 <= int(l[2]) <= 10 ** 8) and (1 <= int(l[3]) <= 10 ** 8):
				break
	d.append(l)
for i in range(len(d)):
	nb = 0
	for j in range(len(d[i])):
		nb = nb + d[i][j]
	if nb % 3 == 0:
		k = nb // 3
		if k >= d[i][0] and k >= d[i][1] and (k >= d[i][2]):
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


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


t = int(input())
for _ in range(t):
	(a, b, c, n) = map(int, input().split())
	if sum([a, b, c, n]) % 3 != 0:
		print('No')
	else:
		x = sum([a, b, c, n]) // 3
		if a <= x and b <= x and (c <= x):
			print('Yes')
		else:
			print('No')


cases = int(input())
for i in range(cases):
	l1 = input().split(' ')
	a = int(l1[0])
	b = int(l1[1])
	c = int(l1[2])
	n = int(l1[3])
	ma = max(a, b, c)
	if a == b == c:
		if n % 3 == 0:
			print('YES')
		else:
			print('NO')
		continue
	if a >= b and a >= c:
		diff = a - b + (a - c)
		c1 = n - diff
		if c1 % 3 == 0 and c1 >= 0:
			print('YES')
		else:
			print('NO')
		continue
	elif b >= a and b >= c:
		diff = b - a + (b - c)
		c2 = n - diff
		if c2 % 3 == 0 and c2 >= 0:
			print('YES')
		else:
			print('NO')
		continue
	elif c >= a and c >= b:
		diff = c - a + (c - b)
		c3 = n - diff
		if c3 % 3 == 0 and c3 >= 0:
			print('YES')
		else:
			print('NO')
		continue


t = int(input())
ans = []
for _ in range(t):
	(a, b, c, s) = map(int, input().split())
	temp = a + b + c + s
	z = temp // 3
	if temp % 3 == 0:
		if z - a >= 0 and z - b >= 0 and (z - c >= 0):
			ans.append('YES')
		else:
			ans.append('NO')
	else:
		ans.append('NO')
for i in ans:
	print(i)


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


t = int(input())
while t > 0:
	[a, b, c, n] = list(map(int, input().split()))
	r = n - (3 * max(a, b, c) - (a + b + c))
	if r < 0 or r % 3:
		print('NO')
	else:
		print('YES')
	t -= 1


def main():
	for _ in range(int(input())):
		l = [int(x) for x in input().split()]
		p = l[-1]
		l = l[:-1]
		l.sort()
		dif = 0
		dif += l[2] - l[1]
		dif += l[2] - l[0]
		p -= dif
		if p >= 0 and p % 3 == 0:
			print('YES')
		else:
			print('NO')
main()


for tc in [0] * int(input()):
	a = list(map(int, input().split()))
	if sum(a) % 3 == 0:
		if max(a[:-1]) * 3 <= sum(a):
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


import sys
I = sys.stdin.readline
ans = ''
for i in range(int(I())):
	(a, b, c, n) = map(int, I().split())
	x = max(a, b, c)
	n -= x - a + (x - b) + (x - c)
	if n % 3 == 0 and n >= 0:
		ans += 'YES\n'
	else:
		ans += 'NO\n'
print(ans)


t = int(input())
for i in range(t):
	l = list(map(int, input().split()))
	s = sum(l)
	if s % 3 == 0:
		p = s / 3
		d = max(l[0], l[1])
		d = max(d, l[2])
		if d <= p:
			print('YES', end='')
		else:
			print('NO', end='')
	else:
		print('NO', end='')
	if i < t - 1:
		print()


for _ in range(int(input())):
	(a, b, c, n) = map(int, input().split())
	max_e = max(a, b, c)
	rem = 3 * max_e - (a + b + c)
	rem = n - rem
	if rem < 0:
		print('NO')
		continue
	elif rem % 3 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
cases = []
while t > 0:
	cases.append([int(x) for x in input().split(' ')])
	t -= 1
for case in cases:
	n = case[3]
	del case[3]
	case.sort()
	n -= case[2] - case[1]
	case[1] = case[2]
	n -= case[2] - case[0]
	case[0] = case[2]
	if (n % 3 == 0 or n == 0) and n >= 0:
		print('YES')
		continue
	elif n < 0 or n % 3:
		print('NO')


t = int(input())
for _ in range(t):
	x = list(map(int, input().split()))
	a = x[0]
	b = x[1]
	c = x[2]
	n = x[3]
	m = max(a, b, c)
	n = n - 3 * m + a + b + c
	if n < 0:
		print('NO')
	elif n % 3 == 0:
		print('YES')
	else:
		print('NO')


def checkAns(a, b, c, n):
	if a == b and b == c:
		if n % 3 == 0:
			print('YES')
		else:
			print('NO')
	else:
		mx = max(a, b)
		mx = max(mx, c)
		sm = mx - a + (mx - b) + (mx - c)
		if n - sm == 0 or ((n - sm) % 3 == 0 and n - sm > 0):
			print('YES')
		else:
			print('NO')
t = int(input())
for i in range(t):
	(a, b, c, n) = map(int, input().split(' '))
	checkAns(a, b, c, n)


import os
import sys
from io import BytesIO, IOBase

def solve():
	(a, b, c, n) = map(int, input().split())
	if a == b == c:
		if n % 3 == 0:
			return 'YES'
		else:
			return 'NO'
	if max(a, b, c) == a:
		if a - b + a - c > n:
			return 'NO'
		elif (n - (a - b) - (a - c)) % 3 != 0:
			return 'NO'
		else:
			return 'YES'
	if max(a, b, c) == b:
		if b - a + b - c > n:
			return 'NO'
		elif (n - (b - a) - (b - c)) % 3 != 0:
			return 'NO'
		else:
			return 'YES'
	if max(a, b, c) == c:
		if c - b + c - a > n:
			return 'NO'
		elif (n - (c - a) - (c - b)) % 3 != 0:
			return 'NO'
		else:
			return 'YES'

def main():
	for _ in range(int(input())):
		print(solve())
	pass
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')
main()


q = int(input())
for _ in range(q):
	(a, b, c, n) = list(map(int, input().split()))
	if (a + b + c + n) % 3 != 0:
		print('NO')
		continue
	expected = (a + b + c + n) // 3
	found = True
	for num in [a, b, c]:
		if num > expected:
			found = False
			break
	if found:
		print('YES')
	else:
		print('NO')


import sys
import bisect
import heapq
from math import *
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
mod = pow(10, 9) + 7

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

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 graph(vertex):
	return [[] for i in range(0, vertex + 1)]

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 solve():
	a = lis()
	if sum(a) % 3 == 0 and (a[0] <= sum(a) // 3 and a[1] <= sum(a) // 3 and (a[2] <= sum(a) // 3)):
		print('YES')
	else:
		print('NO')
testcase(int(inp()))


t = int(input())
for each in range(t):
	arr = [int(i) for i in input().split()]
	n = arr[3]
	tsum = sum(arr)
	arr.pop(3)
	if tsum % 3 == 0:
		p = tsum / 3
		if p < max(arr):
			print('NO')
		else:
			print('YES')
	else:
		print('NO')


import sys
reader = (line.rstrip() for line in sys.stdin)
input = reader.__next__
t = int(input())
for _ in range(t):
	(a, b, c, n) = map(int, input().split())
	if (a + b + c + n) % 3 == 0:
		each = (a + b + c + n) // 3
		if a <= each and b <= each and (c <= each):
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


m = int(input())
for i in range(m):
	l1 = list(map(int, input().split()))
	n = l1[3]
	l1.remove(l1[3])
	l1.sort()
	x = l1[2] - l1[0] + (l1[2] - l1[1])
	n = n - x
	if n < 0:
		print('NO')
	elif n % 3 == 0:
		print('YES')
	else:
		print('NO')


T = int(input().strip())
for t in range(T):
	(a, b, c, n) = map(int, input().split())
	x = max(a, b, c)
	d = x - a + (x - b) + (x - c)
	if n - d == 0 or (n - d > 0 and (n - d) % 3 == 0):
		print('YES')
	else:
		print('NO')


t = int(input())
while t > 0:
	t = t - 1
	(a, b, c, n) = map(int, input().split())
	if (a + b + c + n) % 3 == 0:
		k = (a + b + c + n) // 3
		A = abs(k - a)
		B = abs(k - b)
		C = abs(k - c)
		if A + B + C == n:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(a, b, c, n) = map(int, input().split())
	if (a + b + c + n) % 3:
		print('NO')
		continue
	if max(a, b, c) > (a + b + c + n) // 3:
		print('NO')
	else:
		print('YES')


from math import ceil, floor
t = int(input())
for _ in range(t):
	(a, b, c, n) = map(int, input().split())
	avg = float(a + b + c + n) / 3
	av = int(avg)
	if ceil(avg) == floor(avg) and (a + b + c + n) % 3 == 0 and (a <= av) and (b <= av) and (c <= av):
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(a, b, c, n) = map(int, input().split())
	l = [a, b, c]
	f = 0
	m = max(l)
	for i in range(len(l)):
		g = m - l[i]
		l[i] = l[i] + g
		n = n - g
		if n < 0:
			f = 1
			break
	if f == 1:
		print('NO')
	elif n % 3 == 0:
		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 ll[mid] == val:
			return ll[mid]
		elif ll[mid] < val:
			ans = ll[mid]
			return binary(mid + 1, r, ll, val, ans)
		else:
			return binary(l, mid - 1, ll, val, ans)

def check(n):
	v = 1
	while n != 0:
		if n % 10 == 0 or n % 10 == 1:
			n = n // 10
		else:
			v = 0
			break
	return v
t = int(input())
for i in range(t):
	(a, b, c, n) = map(int, input().split(' '))
	l = []
	l.append(a)
	l.append(b)
	l.append(c)
	l.sort()
	if n >= abs(l[2] - l[1]) + abs(l[2] - l[0]) and (n - abs(l[0] - l[2]) - abs(l[2] - l[1])) % 3 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	arr = [int(x) for x in input().split()]
	n = arr[3]
	arr.pop(3)
	arr.sort()
	buffer = arr[2] - arr[1] + (arr[2] - arr[0])
	if n > 0:
		if buffer <= n and (n - buffer) % 3 == 0:
			print('YES')
		else:
			print('NO')
	elif buffer == 0:
		print('YES')
	else:
		print('NO')


import sys
t = int(sys.stdin.readline())
for _ in range(t):
	(a, b, c, n) = map(int, sys.stdin.readline().split())
	sumVal = a + b + c + n
	if sumVal % 3 == 0:
		temp1 = sumVal // 3
		temp2 = 0
		arr = [a, b, c]
		judge1 = True
		for i in range(len(arr)):
			if arr[i] <= temp1:
				temp2 += temp1 - arr[i]
			else:
				print('NO')
				judge1 = False
				break
		if judge1 == True:
			if temp2 == n:
				print('YES')
			else:
				print('NO')
	else:
		print('NO')


n = int(input())
ans1 = []
for i in range(n):
	abcn = input().split()
	a = int(abcn[0])
	b = int(abcn[1])
	c = int(abcn[2])
	n = int(abcn[3])
	m = max(a, b, c)
	g = 3 * m - a - b - c
	if g > n or (n - g) % 3 != 0:
		ans1.append('NO')
	else:
		ans1.append('YES')
for i in ans1:
	print(i)


t = int(input())
for _ in range(t):
	(a, b, c, n) = map(int, input().split())
	su = a + b + c + n
	if su % 3 != 0:
		print('NO')
	else:
		share = su // 3
		m = max(a, b, c)
		if share >= m:
			print('YES')
		else:
			print('NO')


for _ in range(int(input())):
	(a, b, c, n) = map(int, input().split())
	m = max(a, b, c)
	ans = 3 * m - a - b - c
	if ans > n:
		print('NO')
	else:
		q = ans - n
		if q % 3 == 0:
			print('YES')
		else:
			print('NO')


import math
s = 0
for i in range(int(input())):
	(a, b, c, d) = map(int, input().split())
	l = sum([a, b, c, d])
	p = max(a, b, c)
	x = l // 3
	n = x - a + x - b + x - c
	if l % 3 == 0 and p <= x:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	l = [int(i) for i in input().split()]
	a = l[0]
	b = l[1]
	c = l[2]
	n = l[-1]
	A = (n - 2 * a + b + c) / 3
	B = (n + a - 2 * b + c) / 3
	C = (n + a - 2 * c + b) / 3
	if sum(l) % 3 == 0:
		if A >= 0 and B >= 0 and (C >= 0) and (A + B + C == n) and (a + A == b + B == c + C):
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


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


t = int(input())
for i in range(t):
	num_input = input()
	num_input = num_input.split(' ')
	a = int(num_input[0])
	b = int(num_input[1])
	c = int(num_input[2])
	n = int(num_input[3])
	x = -1
	if (a + b + c + n) % 3 == 0:
		x = (a + b + c + n) / 3
	if x >= 0 and x - a >= 0 and (x - b >= 0) and (x - c >= 0):
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	count = 0
	l = list(map(int, input().strip().split()))
	a = l[0]
	b = l[1]
	c = l[2]
	d = max(a, b, c)
	count = count + d - a + d - b + d - c
	n = l[3]
	n = n - count
	if n >= 0 and n % 3 == 0:
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	a = [int(i) for i in input().split()]
	q = a[-1]
	a.pop(-1)
	a.sort()
	f = a[-1] - a[0]
	g = a[-1] - a[1]
	q -= f + g
	if q >= 0:
		if q % 3 == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


from sys import stdin, stdout

def main():
	t = int(input())
	for z in range(t):
		(a, b, c, n) = map(int, input().split())
		if (a + b + c + n) % 3 == 0 and max(a, b, c) <= (a + b + c + n) // 3:
			print('YES')
		else:
			print('NO')
main()


getLimit = int(input())
Result = []
for i in range(0, getLimit):
	NO = False
	Candy_List = list(map(int, input().strip().split()))[0:4]
	if sum(Candy_List) % 3 == 0:
		Checker = sum(Candy_List) / 3
		for j in Candy_List[0:3]:
			if Checker - j < 0:
				NO = True
				break
		if NO == True:
			Result.append('NO')
		elif NO == False:
			Result.append('YES')
	else:
		Result.append('NO')
for i in Result:
	print(i)


t = int(input())
a = 0
b = 0
c = 0
n = 0
for i in range(0, t):
	s = input()
	ss = s.split()
	a = int(ss[0])
	b = int(ss[1])
	c = int(ss[2])
	n = int(ss[3])
	del s, ss
	if (n + a + b + c) % 3 == 0 and (n + a + b + c) / 3 >= max(a, b, c):
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(*A, n) = map(int, input().split())
	s = sum(A) + n
	print('NO' if 3 * max(A) > s or s % 3 else 'YES')


t = int(input())
while t:
	t = t - 1
	l = [int(i) for i in input().split()]
	n = l[-1]
	l = l[:-1]
	l.sort(reverse=1)
	s = l[0] - l[1] + (l[0] - l[2])
	n = n - s
	if n >= 0:
		if n % 3 == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


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


n = int(input())
for _ in range(n):
	c = [int(x) for x in input().split()]
	(q, r) = divmod(sum(c), 3)
	if r != 0:
		print('NO')
	elif sum([q - x for x in c[0:-1] if q - x >= 0]) == c[-1]:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(a, b, c, n) = map(int, input().split())
	l = [a, b, c]
	l.sort()
	x = n - (l[2] - l[0]) - (l[2] - l[1])
	if x < 0 or x % 3 != 0:
		print('NO')
	else:
		print('YES')


t = int(input())
for tt in range(t):
	(a, b, c, n) = map(int, input().split())
	dot = [a, b, c]
	dot.sort()
	r = dot[2] - dot[1] + dot[2] - dot[0]
	if n - r >= 0 and (n - r) % 3 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(a, b, c, n) = tuple(map(int, input().split()))
	total = a + b + c + n
	if total % 3 != 0:
		print('NO')
	else:
		per = total / 3
		if per >= a and per >= b and (per >= c):
			print('YES')
		else:
			print('NO')


t = int(input())
for _ in range(t):
	(k, b, c, n) = map(int, input().split())
	a = []
	a.append(k)
	a.append(b)
	a.append(c)
	a.sort()
	x = a[2] - a[0]
	y = a[2] - a[1]
	n = n - y - x
	if n >= 0 and n % 3 == 0:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	a = list(map(int, input().split()))
	m = max(a[:-1])
	s = sum(a)
	print('YES' if s % 3 == 0 and s // 3 >= m else 'NO')


for _ in range(int(input())):
	l = list(map(int, input().split()))
	n = l.pop()
	x = max(l)
	sum = x - l[0] + (x - l[1]) + (x - l[2])
	if n < sum:
		print('NO')
	elif (n - sum) % 3 == 0:
		print('YES')
	else:
		print('NO')


from sys import stdin, stdout
t = 1
t = int(input())
for i in range(t):
	(a, b, c, n) = map(int, input().split())
	s = a + b + c + n
	if s % 3:
		print('NO')
		continue
	d = s // 3
	if d < a or d < b or d < c:
		print('NO')
	else:
		print('YES')


from math import ceil, sqrt, floor
n = int(input())
for i in range(n):
	(a, b, c, n) = map(int, input().split())
	(a, b, c) = sorted([a, b, c])
	if n >= 2 * c - a - b and (not (n - (2 * c - a - b)) % 3):
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	l = [int(i) for i in input().split()]
	f = l[len(l) - 1]
	l.remove(f)
	max1 = max(l)
	d = 0
	for i in l:
		if i < max1:
			d = d + (max1 - i)
	if f - d == 0:
		print('YES')
	elif (f - d) % len(l) == 0 and f - d > 0:
		print('YES')
	else:
		print('NO')


def solve(a, b, c, n):
	m = [a, b, c]
	m.sort()
	n = n - (m[2] - m[1])
	n = n - (m[2] - m[0])
	if n % 3 == 0 and n >= 0:
		print('YES')
	else:
		print('NO')

def main():
	for i in range(int(input())):
		f = [int(x) for x in input().split()]
		solve(f[0], f[1], f[2], f[3])
main()


n = int(input())
for i in range(n):
	(a, b, c, n) = [int(x) for x in input().split(' ')]
	ma = max(a, b, c)
	tmp = [a, b, c]
	tmp.remove(ma)
	if (n - (ma - tmp[0] + ma - tmp[1])) % 3 == 0 and n - (ma - tmp[0] + ma - tmp[1]) >= 0:
		print('YES')
	else:
		print('NO')


def find(n, su):
	if su > n:
		return False
	else:
		diff = n - su
		if diff % 3 == 0:
			return True
		else:
			return False
for _ in range(int(input())):
	(a, b, c, n) = list(map(int, input().split()))
	m = max(max(a, b), c)
	su = 0
	su += m - a
	su += m - b
	su += m - c
	if find(n, su):
		print('YES')
	else:
		print('NO')


t = int(input())
for p in range(t):
	coins_info = list(map(int, input().split()))
	a = coins_info[0]
	b = coins_info[1]
	c = coins_info[2]
	n = coins_info[3]
	d = max(a, b, c)
	sum_diff = d - a + d - b + d - c
	if sum_diff > n:
		print('NO')
	else:
		n = n - sum_diff
		if n % 3 == 0:
			print('YES')
		else:
			print('NO')


answers = []

def get_answer():
	n = int(input())
	for i in range(n):
		l = list(map(int, input().split()))
		m = max(l[:-1])
		n = l[-1]
		for e in l[:-1]:
			if e != m:
				n -= m - e
		if n % 3 == 0 and n >= 0:
			answers.append('YES')
		else:
			answers.append('NO')
	for a in answers:
		print(a)
get_answer()


def program():
	(a, b, c, n) = map(int, input().split())
	m = max(a, b, c)
	s = 3 * m - (a + b + c)
	n = n - s
	if n < 0:
		print('NO')
	elif n % 3 == 0:
		print('YES')
	else:
		print('NO')
t = int(input())
for i in range(t):
	program()


import sys
input = sys.stdin.readline
t = int(input())
for test in range(t):
	(a, b, c, n) = list(map(int, input().split()))
	M = max(a, b, c)
	n -= M - a + (M - b) + (M - c)
	if n < 0:
		print('NO')
	elif n % 3 == 0:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(a, b, c, n) = map(int, input().split())
	lis = [a, b, c]
	lis.sort()
	a1 = lis[0]
	b1 = lis[1]
	c1 = lis[2]
	sum1 = lis[2] - lis[1] + lis[2] - lis[0]
	sum2 = n - sum1
	if sum2 < 0:
		print('NO')
	elif sum2 % 3 == 0:
		print('YES')
	else:
		print('NO')


testcases = int(input())
while testcases > 0:
	testcases -= 1
	coins = list(map(int, input().split()))
	n = coins[3]
	del coins[3]
	coins.sort(reverse=True)
	(b, c) = (coins[0] - coins[1], coins[0] - coins[2])
	n = n - b - c
	if n % 3 == 0 and n >= 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	result = ' '
	array = []
	res_array = []
	(a, b, c, n) = map(int, input().split())
	array.append(a)
	array.append(b)
	array.append(c)
	array.sort()
	deffernce = array[2] - array[1] + (array[2] - array[0])
	if n >= deffernce:
		if (n - deffernce) % 3 == 0:
			result = 'YES'
			print(result)
		else:
			print('NO')
	elif n < deffernce or deffernce == 0:
		result = 'NO'
		print(result)


n = int(input())
for i in range(n):
	(a, b, c, d) = map(int, input().split())
	suubtractt = max(a, b, c)
	suuubtracttt = suubtractt - a + suubtractt - b + suubtractt - c
	if d > suuubtracttt:
		if (d - suuubtracttt) / 3 % 1 == 0:
			print('YES')
		else:
			print('NO')
	elif d == suuubtracttt:
		print('YES')
	else:
		print('NO')


def distribute_coins(a, b, c, n):
	if a > b:
		(a, b) = (b, a)
	if b > c:
		(b, c) = (c, b)
	if a > b:
		(a, b) = (b, a)
	if n < 2 * c - b - a:
		return 'NO'
	if (n - (2 * c - b - a)) % 3 == 0:
		return 'YES'
	else:
		return 'NO'
t = int(input())
for i in range(t):
	(a, b, c, n) = map(int, input().split())
	result = distribute_coins(a, b, c, n)
	print(result)


for _ in range(int(input())):
	(a, b, c, n) = map(int, input().split())
	flag = False
	m = max(a, b, c)
	required = 3 * m - (a + b + c)
	if required > n:
		print('NO')
	else:
		n = n - required
		if n % 3 == 0:
			print('YES')
		else:
			print('NO')


import math
import os

def get_array():
	return list(map(int, input().split(' ')))
t = int(input())
for i in range(t):
	(a, b, c, n) = get_array()
	r = max([a, b, c])
	rr = r - a + r - b + r - c
	if rr <= n and (n - rr) % 3 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
ans = []
for _ in range(t):
	s = input().split()
	numbers = []
	for i in range(3):
		numbers.append(int(s[i]))
	n = int(s[3])
	m = numbers[0]
	ind = 0
	for i in range(3):
		if numbers[i] > m:
			m = numbers[i]
			ind = i
	for i in range(3):
		if i != ind:
			n -= numbers[ind] - numbers[i]
	if n % 3 == 0 and n >= 0:
		ans.append('YES')
	else:
		ans.append('NO')
for x in ans:
	print(x)


q = int(input())
for i in range(q):
	(a, b, c, s) = map(int, input().split())
	x = a + b + c + s
	if x % 3 != 0:
		print('NO')
	else:
		x = x // 3
		if a > x or b > x or c > x:
			print('NO')
		else:
			print('YES')


def is_yes(a, b, c, n):
	abc = sorted([a, b, c])
	r = abc[2] - abc[1] + (abc[2] - abc[0])
	if n >= r:
		n -= r
		if n % 3 == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')
t = int(input())
for i in range(t):
	(a, b, c, n) = map(int, input().split())
	is_yes(a, b, c, n)


n = int(input())
for i in range(n):
	l1 = [int(i) for i in input().split(' ')]
	t = l1[-1]
	l1.remove(l1[-1])
	l1 = sorted(l1)
	m = l1[2] - l1[0]
	a = l1[2] - l1[1]
	k = m + a
	if k > t:
		print('NO')
	elif (t - k) % 3 == 0 or t - k == 0:
		print('YES')
	else:
		print('NO')


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


for i in range(int(input())):
	(a, b, c, n) = map(int, input().split())
	flag = 0
	temp = a + b + c + n
	if temp % 3 != 0:
		flag = 0
	else:
		x = temp // 3 - a
		y = temp // 3 - b
		z = temp // 3 - c
		if x >= 0 and y >= 0 and (z >= 0):
			flag = 1
	if flag:
		print('YES')
	else:
		print('NO')


T = int(input())
while T:
	n = list(map(int, input().split()))
	bro = n[-1]
	(a, b, c) = (n[0], n[1], n[2])
	maxim = max(a, b, c)
	bro -= maxim - a
	bro -= maxim - b
	bro -= maxim - c
	if bro >= 0 and bro % 3 == 0:
		print('YES')
	else:
		print('NO')
	T -= 1


n = int(input())
for i in range(n):
	l = []
	p = 0
	(a, b, c, n) = map(int, input().split())
	l.append(a)
	l.append(b)
	l.append(c)
	p = p + max(l) - a
	p = p + max(l) - b
	p = p + max(l) - c
	if (n - p) % 3 == 0 and n >= p:
		print('YES')
	else:
		print('NO')


tests = int(input())
for _ in range(tests):
	(a, b, c, n) = [int(x) for x in input().split()]
	rem = (a + b + c + n) % 3
	if rem == 0:
		to_give = (a + b + c + n) // 3
		if to_give - a < 0 or to_give - b < 0 or to_give - c < 0:
			print('NO')
		else:
			print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(A, B, C, N) = list(map(int, input().split()))
	M = max(A, B, C)
	S = sum(list(map(lambda x: M - x, [A, B, C])))
	print('YES' if N - S >= 0 and (N - S) % 3 == 0 else 'NO')


for i in range(int(input())):
	(a, b, c, n) = map(int, input().split())
	l = []
	l.append(a)
	l.append(b)
	l.append(c)
	l.sort()
	p = l[0]
	q = l[1]
	d = l[2]
	m = d - p
	h = d - q
	r = m + h
	if r <= n and (n - r) % 3 == 0:
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	a = [int(x) for x in input().split()]
	n = a[3]
	a.pop(3)
	a.sort()
	buf = a[2] - a[1] + (a[2] - a[0])
	if n > 0:
		if buf <= n and (n - buf) % 3 == 0:
			print('YES')
		else:
			print('NO')
	elif buf == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
while t > 0:
	t = t - 1
	(a, b, c, n) = map(int, input().split())
	if b > a:
		d = a
		a = b
		b = d
	if c > b:
		d = c
		c = b
		b = d
	if b > a:
		d = a
		a = b
		b = d
	x = a - b
	y = a - c
	n -= x + y
	if n >= 0:
		if n % 3 == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


t = int(input())
for i in range(t):
	l = list(map(int, input().split()))
	n = l[3]
	l.pop(3)
	i = 0
	while True:
		if n < 0:
			print('NO')
			break
		elif l[0] == max(l) and l[1] == max(l) and (l[2] == max(l)):
			if n < 0:
				print('NO')
				break
			elif n == 0 or n % 3 == 0:
				print('YES')
				break
			else:
				print('NO')
				break
		elif l[i] == max(l):
			pass
		else:
			n = n - (max(l) - l[i])
			l[i] = max(l)
		i += 1


t = int(input())
for _ in range(t):
	(a, b, c, n) = map(int, input().split())
	print(['NO', 'YES'][(n - (3 * max(a, b, c) - a - b - c)) % 3 == 0 and n - (3 * max(a, b, c) - a - b - c) >= 0])


for _ in range(int(input())):
	(a, b, c, n) = list(map(int, input().split()))
	k = max(a, b, c)
	this = 3 * k - (a + b + c)
	if n < this:
		print('NO')
		continue
	else:
		j = n - this
		if j % 3 == 0:
			print('YES')
		else:
			print('NO')


results = []
for _ in range(int(input())):
	row = [int(i) for i in input().split()]
	n = row[3]
	s_row = sorted(row[:-1])
	reste = n - 2 * s_row[2] + s_row[0] + s_row[1]
	if reste < 0 or reste % 3:
		results.append('NO')
	else:
		results.append('YES')
for r in results:
	print(r)


for i in range(int(input())):
	x = list(map(int, input().split()))
	X = sum(x)
	if X % 3 == 0:
		if X // 3 >= x[0] and X // 3 >= x[1] and (X // 3 >= x[2]):
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	L = list(map(int, input().split()))
	maxxxx = max(L[0:3])
	for i in range(3):
		L[3] = L[3] - (maxxxx - L[i])
		L[i] += maxxxx - L[i]
	if all((x == L[0] for x in L[0:3])) and L[3] % 3 == 0 and (L[3] >= 0):
		print('YES')
	else:
		print('NO')


t = int(input())
for test in range(t):
	(a, b, c, n) = [int(x) for x in input().split()]
	x = max(a, b, c)
	if a < x:
		n = n - (x - a)
	if b < x:
		n = n - (x - b)
	if c < x:
		n = n - (x - c)
	if n < 0:
		print('NO')
	elif n % 3 != 0:
		print('NO')
	else:
		print('YES')


t = int(input())
while t > 0:
	t = t - 1
	(a, b, c, n) = map(int, input().split())
	m = max(a, b, c)
	k = abs(m - a) + abs(m - b) + abs(m - c)
	n = n - k
	if n < 0:
		print('NO')
		continue
	if n % 3 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
answers = []
for testcase in range(t):
	(a, b, c, n) = map(int, input().split())
	maximum = max([a, b, c])
	tot = 0
	for i in [a, b, c]:
		tot += maximum - i
	if tot <= n and (n - tot) % 3 == 0:
		answers.append('YES')
	else:
		answers.append('NO')
for res in answers:
	print(res)


t = int(input())
for i in range(0, t):
	s = list(map(int, input().split()))
	a = s[0]
	b = s[1]
	c = s[2]
	n = s[3]
	su = a + b + c + n
	s.pop()
	s.sort()
	ma = s[2]
	me = s[1]
	mi = s[0]
	x = ma - me
	y = ma - mi
	z = x + y
	if n >= z and su % 3 == 0:
		print('YES')
	else:
		print('NO')


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


for _ in range(int(input())):
	(a, b, c, n) = map(int, input().split())
	l = [a, b, c]
	l = sorted(l)
	(x, y) = (l[2] - l[0], l[2] - l[1])
	z = n - x - y
	if z < 0:
		print('NO')
	elif z % 3 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	l = list(map(int, input().split()))
	n = l[3]
	k = sorted(l[:3])
	if (k[0] != k[1] or k[1] != k[2] or k[0] != k[2]) and n == 0:
		print('NO')
	else:
		o = k[2] - k[0]
		g = k[2] - k[1]
		n = n - o - g
		if n < 0:
			print('NO')
		elif n % 3 == 0:
			print('YES')
		else:
			print('NO')


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


for _ in range(int(input())):
	(a, b, c, n) = [int(i) for i in input().split()]
	ans = max(a, b, c)
	if (n - (3 * ans - (a + b + c))) % 3 == 0 and n - (3 * ans - (a + b + c)) >= 0:
		print('YES')
	else:
		print('NO')


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


t = int(input())
for ii in range(t):
	(a, b, c, n) = [int(x) for x in input().split()]
	k = max(a, b, c)
	s = k - a + k - b + k - c
	if s > n:
		print('NO')
	else:
		n -= s
		if n % 3 == 0:
			print('YES')
		else:
			print('NO')


import os
t = int(input())
for t in range(0, t):
	x = list(map(int, input().split(' ')))
	a = x[0]
	b = x[1]
	c = x[2]
	n = x[3]
	l = max(a, b, c)
	p = 3 * l - a - b - c
	if p > n:
		print('NO')
	elif (n - p) % 3 != 0:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	(a, b, c, n) = map(int, input().split())
	res = a + b + c
	e = (n + res) // 3
	x = e - a
	y = e - b
	z = e - c
	if x + y + z == n and x >= 0 and (y >= 0) and (z >= 0):
		print('YES')
	else:
		print('NO')


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 : list(map(int, input().split()))
go = lambda : 1 / 0

def write(*args, sep='\n'):
	for i in args:
		sys.stdout.write('{}{}'.format(i, sep))
INF = float('inf')
MOD = int(1000000000.0 + 7)
YES = 'YES'
NO = 'NO'
for _ in range(int(input())):
	try:
		(a, b, c, n) = read()
		x = max([a, b, c])
		n -= x - a
		n -= x - b
		n -= x - c
		if n < 0:
			print(NO)
			go()
		if n % 3 == 0:
			print(YES)
		else:
			print(NO)
	except:
		continue


for i in range(int(input())):
	p = list(map(int, input().split()))
	if sum(p) % 3 == 0 and sum(p) / 3 >= max(p[:3]):
		print('YES')
	else:
		print('NO')


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


def coins(l):
	(a, b, c, n) = (l[0], l[1], l[2], l[3])
	m = max(a, b, c)
	s = a + b + c
	if n < 3 * m - s:
		return 'NO'
	d = m - a + (m - b) + (m - c)
	if (n - d) % 3 == 0:
		return 'YES'
	return 'NO'
for t in range(int(input())):
	l = list(map(int, input().split()))
	print(coins(l))


tasks_number = int(input())
for i in range(tasks_number):
	(a, b, c, n) = map(int, input().split())
	if (a + b + c + n) % 3 == 0:
		threshold = (a + b + c + n) / 3
		if a <= threshold and b <= threshold and (c <= threshold):
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


def solve():
	(a, b, c, n) = [int(i) for i in input().split()]
	q = n + (a + b + c)
	if q % 3 == 0 and q // 3 >= max(a, b, c):
		return 'YES'
	return 'NO'
t = int(input())
ans = []
while t:
	ans.append(str(solve()))
	t -= 1
print('\n'.join(ans))


n = int(input())
while n > 0:
	x = list(map(int, input().split()))
	y = x.pop()
	x.sort()
	y += x[1] - x[2]
	y += x[0] - x[2]
	if y == 0:
		print('YES')
	elif y > 0:
		if y % 3 == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')
	n -= 1


t = int(input())
for qwe in range(t):
	(a, b, c, n) = map(int, input().split())
	flag = True
	if (a + b + c + n) % 3 == 0:
		summ = a + b + c + n
		summ //= 3
		if summ - a >= 0 and summ - b >= 0 and (summ - c >= 0):
			flag = True
		else:
			flag = False
	else:
		flag = False
	if flag:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	a = list(map(int, input().split()))
	if a[0] == a[1] and a[1] == a[2] and (a[3] % 3 == 0):
		print('YES')
	elif a[0] == a[1] and a[1] == a[2] and (a[3] % 3 != 0):
		print('NO')
	else:
		b = [a[0], a[1], a[2]]
		b = sorted(b)
		val = a[3]
		val = val - (b[2] - b[1]) - (b[2] - b[0])
		if val < 0 or val % 3 != 0:
			print('NO')
		else:
			print('YES')


number_of_cases = int(input())

def isDivisable(test_case):
	n = test_case[3]
	sisters = test_case[:3]
	sisters.sort(reverse=True)
	numberToAdd = 2 * sisters[0] - sisters[1] - sisters[2]
	if (n - numberToAdd) % 3 == 0 and n - numberToAdd >= 0:
		return 'YES'
	else:
		return 'NO'
for i in range(number_of_cases):
	test_case = [int(x) for x in input().split()]
	print(isDivisable(test_case))


from sys import stdin, stdout

def main():
	t = int(input())
	for z in range(t):
		(a, b, c, n) = map(int, input().split())
		arr = [a, b, c]
		arr.sort()
		if n >= arr[2] * 2 - arr[0] - arr[1] and (n - (arr[2] * 2 - arr[0] - arr[1])) % 3 == 0:
			print('YES')
		else:
			print('NO')
main()


t = int(input())
for _ in range(t):
	(a, b, c, n) = [int(i) for i in input().split()]
	p = max((a, b, c))
	w = a + b + c + n - 3 * p
	print(['NO', 'YES'][w >= 0 and w % 3 == 0])


n = int(input())
for _ in range(n):
	a = [int(x) for x in input().split()]
	n = a[3]
	a.pop(3)
	a.sort()
	tmp = a[2] - a[1] + (a[2] - a[0])
	if n > 0:
		if tmp <= n and (n - tmp) % 3 == 0:
			print('YES')
		else:
			print('NO')
	elif tmp == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for r in range(t):
	(a, b, c, n) = map(int, input().split())
	s = (a + b + c + n) // 3
	if (a + b + c + n) % 3 == 0 and a <= s and (b <= s) and (c <= s):
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(a, b, c, n) = map(int, input().split())
	m = max(a, b, c)
	(a, b, c) = (m - a, m - b, m - c)
	c = a + b + c
	flag = 'YES'
	if n >= c and (n - c) % 3 == 0:
		pass
	else:
		flag = 'NO'
	print(flag)


def answer():
	n = int(input())
	c_out = []
	while n:
		a = input().split()
		a = [int(x) for x in a]
		if sum(a) % 3:
			c_out.append('NO')
		else:
			c = max(a[:3])
			d = [c - x for x in a[:3]]
			if sum(d) > a[3]:
				c_out.append('NO')
			else:
				c_out.append('YES')
		n -= 1
	for x in c_out:
		print(x)
answer()


T = int(input())
while T:
	nums = list(map(int, input().split()))
	bro = nums[-1]
	(a, b, c) = (nums[0], nums[1], nums[2])
	maxi = max(a, b, c)
	bro -= maxi - a
	bro -= maxi - b
	bro -= maxi - c
	if bro >= 0 and bro % 3 == 0:
		print('YES')
	else:
		print('NO')
	T -= 1


t = int(input())
for i in range(t):
	(a, b, c, n) = list(map(int, input().split()))
	s = a + b + c + n
	if s % 3 != 0:
		print('NO')
	else:
		g = s // 3
		na = g - a
		nb = g - b
		nc = g - c
		if na >= 0 and nb >= 0 and (nc >= 0) and (na + nb + nc == n):
			print('YES')
		else:
			print('NO')


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


def solve(a, b, c, n):
	initial_max = max(a, b, c)
	needed_to_equalize = initial_max - a + (initial_max - b) + (initial_max - c)
	n -= needed_to_equalize
	return 'YES' if n >= 0 and n % 3 == 0 else 'NO'
t = int(input())
results = list()
for _ in range(0, t):
	(a, b, c, n) = map(int, input().split(' '))
	results.append(solve(a, b, c, n))
for result in results:
	print(result)


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


x = int(input())
for i in range(x):
	Z = list(map(int, input().split()))
	J = sum(Z)
	P = max(Z[0:3])
	g = J % 3
	k = int(J / 3)
	if g == 0:
		if k >= P:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


for i in range(int(input())):
	(a, b, c, n) = map(int, input().split())
	k = a + b + c + n
	if k % 3 == 0 and max(a, b, c) <= k / 3:
		print('YES')
	else:
		print('No')


def possible(a, b, c, n):
	m = max(a, b, c)
	s = m - a + (m - b) + (m - c)
	return s <= n and (s - n) % 3 == 0
n = int(input())
for i in range(n):
	s = input()
	(a, b, c, n) = (int(x) for x in s.split())
	if possible(a, b, c, n):
		print('YES')
	else:
		print('NO')


import sys
import queue
sys.setrecursionlimit(10 ** 9)
IA = lambda : map(int, input().split())
IAL = lambda : list(map(int, input().split()))
IM = lambda N: [IA() for _ in range(N)]
N = 105
T = int(input())
for i in range(0, T):
	(a, b, c, n) = IA()
	if 2 * max(a, b, c) - (a + b + c - max(a, b, c)) > n:
		print('NO')
	elif (n - (2 * max(a, b, c) - (a + b + c - max(a, b, c)))) % 3 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
k = []
for i in range(t):
	(a, b, c, n) = map(int, input().split())
	mid = a + b + c + n
	if mid % 3 != 0:
		k.append('NO')
	elif max(a, b, c, mid // 3) == mid // 3:
		k.append('YES')
	else:
		k.append('NO')
for i in k:
	print(i)


t = int(input())
while t:
	l = list(map(int, input().split()))
	if sum(l) % 3 == 0:
		x = sum(l) // 3
		if l[0] > x or l[1] > x or l[2] > x:
			print('NO')
		else:
			print('YES')
	else:
		print('NO')
	t -= 1


t = int(input())
for i in range(t):
	h = list(map(int, input().split(' ')))
	(a, b, c, n) = (h[0], h[1], h[2], h[3])
	newlist = [a, b, c]
	newlist.sort()
	diff1 = newlist[1] - newlist[0]
	diff2 = newlist[2] - newlist[1]
	n = n - (diff1 + 2 * diff2)
	print('YES') if n % 3 == 0 and n > -1 else print('NO')


t = int(input())
for w in range(t):
	(a, b, c, n) = (int(i) for i in input().split())
	if (a + b + c + n) % 3 == 0 and max(a, b, c) <= (a + b + c + n) / 3:
		print('Yes')
	else:
		print('No')


count = int(input())
i = 0
while i < count:
	(A, B, C, n) = map(int, input().split())
	summ = A + B + C
	if max(A, B, C) - min(A, B, C) + (max(A, B, C) - (summ - max(A, B, C) - min(A, B, C))) <= n:
		n -= max(A, B, C) - min(A, B, C) + (max(A, B, C) - (summ - max(A, B, C) - min(A, B, C)))
		if n % 3 == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')
	i += 1


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


from math import factorial
from collections import Counter
from sys import stdin

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

def comb(n, m):
	return factorial(n) / (factorial(m) * factorial(n - m)) if n >= m else 0

def perm(n, m):
	return factorial(n) // factorial(n - m) if n >= m else 0

def mdis(x1, y1, x2, y2):
	return abs(x1 - x2) + abs(y1 - y2)
mod = 1000000007
N = int(input())
for _ in range(N):
	(a, b, c, n) = RL()
	ma = max(a, b, c)
	if ma - a + (ma - b) + (ma - c) <= n and (n - (ma - a + (ma - b) + (ma - c))) % 3 == 0:
		print('YES')
	else:
		print('NO')


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


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


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


for _ in range(int(input())):
	(a, b, c, n) = [int(j) for j in input().split()]
	k = max([a, b, c])
	s = sum([k - i for i in [a, b, c]])
	if n >= s and (n - s) % 3 == 0:
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	(a, b, c, d) = map(int, input().split())
	done = False
	while not done:
		x = (d + a + b + c) / 3
		if (d + a + b + c) % 3 == 0 and a <= x and (b <= x) and (c <= x):
			A = x - a
			B = x - b
			C = x - c
			if A + a == B + b == C + c:
				megoldva = True
				print('YES')
				break
			if a == 0 and b == 0 and (c == 0):
				print('YES')
		else:
			print('NO')
			break


import math
from decimal import Decimal
import heapq
import copy
import heapq
from collections import deque

def na():
	n = int(input())
	b = [int(x) for x in input().split()]
	return (n, b)

def nab():
	n = int(input())
	b = [int(x) for x in input().split()]
	c = [int(x) for x in input().split()]
	return (n, b, c)

def dv():
	(n, m) = map(int, input().split())
	return (n, m)

def da():
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	return (n, m, a)

def dva():
	(n, m) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	return (n, m, b)

def eratosthenes(n):
	sieve = list(range(n + 1))
	for i in sieve:
		if i > 1:
			for j in range(i + i, len(sieve), i):
				sieve[j] = 0
	return sorted(set(sieve))

def lol(lst, k):
	k = k % len(lst)
	ret = [0] * len(lst)
	for i in range(len(lst)):
		if i + k < len(lst) and i + k >= 0:
			ret[i] = lst[i + k]
		if i + k >= len(lst):
			ret[i] = lst[i + k - len(lst)]
		if i + k < 0:
			ret[i] = lst[i + k + len(lst)]
	return ret

def nm():
	n = int(input())
	b = [int(x) for x in input().split()]
	m = int(input())
	c = [int(x) for x in input().split()]
	return (n, b, m, c)

def dvs():
	n = int(input())
	m = int(input())
	return (n, m)

def fact(n):
	tc = []
	ans = {}
	d = 2
	while d * d <= n:
		if n % d == 0:
			tc.append(d)
			n //= d
		else:
			d += 1
	if n > 1:
		tc.append(n)
	for i in tc:
		ans[i] = ans.get(i, 0) + 1
	return ans
for i in range(int(input())):
	(a, b, c, n) = map(int, input().split())
	d = sorted([a, b, c])
	rz1 = d[1] - d[0]
	rz2 = d[2] - d[1]
	rz2 *= 2
	n -= rz1
	n -= rz2
	if n >= 0 and n % 3 == 0:
		print('YES')
	else:
		print('NO')


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


n = int(input())
sum = 0
for i in range(n):
	l = list(map(int, input().split()))[:4]
	for i in l:
		sum = sum + i
	l.pop()
	t = sum // 3
	if t >= max(l) and sum % 3 == 0:
		print('YES')
	else:
		print('NO')
	sum = 0


t = int(input())
for _ in range(t):
	(a, b, c, n) = map(int, input().split())
	x = (a + b + c + n) / 3
	diff_a = x - a
	diff_b = x - b
	diff_c = x - c
	if not x.is_integer() or diff_a < 0 or diff_b < 0 or (diff_c < 0):
		print('NO')
	else:
		print('YES')


def main():
	t = int(input())
	for i in range(t):
		(a, b, c, n) = map(int, input().split())
		tmp = (a + b + c + n) // 3
		n = n - (tmp - a + tmp - b + tmp - c)
		if n != 0 or a > tmp or b > tmp or (c > tmp):
			print('NO')
		else:
			print('YES')
main()


t = int(input())
for i in range(t):
	[a, b, c, n] = map(int, input().split())
	s = a + b + c + n
	d = s // 3
	A = d - a
	B = d - b
	C = d - c
	if A >= 0 and B >= 0 and (C >= 0) and (s % 3 == 0):
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	lis = [0] * 3
	(lis[0], lis[1], lis[2], n) = map(int, input().split())
	lis.sort()
	a = lis[2] - lis[0] + lis[2] - lis[1]
	if n < a:
		print('NO')
	elif (n - a) % 3 == 0:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(a, b, c, n) = map(int, input().split())
	maximum = max(a, b, c)
	needed = 3 * maximum - (a + b + c)
	if n >= needed:
		if (n - needed) % 3 == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


for j in range(int(input())):
	a = list(map(int, input().split()))
	if sum(a) % 3 != 0 or max(a[:3]) > sum(a) // 3:
		print('NO')
	else:
		print('YES')


def solve(a, b, c, n):
	tot = a + b + c + n
	if tot % 3 != 0:
		return 'NO'
	each = tot / 3
	if each < a or each < b or each < c:
		return 'NO'
	return 'YES'
t = int(input())
for _ in range(t):
	(a, b, c, n) = [int(x) for x in input().split(' ')]
	print(solve(a, b, c, n))


from collections import deque
import sys

def inp():
	return sys.stdin.readline().strip()
for _ in range(int(inp())):
	(a, b, c, n) = map(int, inp().split())
	sm = a + b + c + n
	if sm % 3 != 0:
		print('No')
		continue
	sm //= 3
	if sm < a or sm < b or sm < c:
		print('No')
	else:
		print('Yes')


n = int(input())
for a in range(n):
	values = list(map(int, input().split()))
	maximum = values[0]
	total = 0
	for a in range(3):
		if values[a] > maximum:
			maximum = values[a]
		total += values[a]
	total += values[3]
	if total % 3 == 0 and total / 3 >= maximum:
		print('YES')
	else:
		print('NO')


def function():
	t = int(input())
	read_input = []
	for x in range(0, t):
		read_input.append(input())
	for x in read_input:
		answer = 'NO'
		numbers = [int(i) for i in x.split(' ')]
		n = numbers.pop()
		maxNumber = max(numbers)
		sum = 0
		for i in numbers:
			sum = sum + maxNumber - i
		if n >= sum and (n - sum) % 3 == 0:
			answer = 'YES'
		print(answer)
function()


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


for i in range(int(input())):
	(a, b, c, n) = (int(x) for x in input().split())
	monMax = max(a, b, c)
	dob = monMax - a + (monMax - b) + (monMax - c)
	if (n - dob) % 3 or n < dob:
		print('NO')
	else:
		print('YES')


T = int(input())
for t in range(T):
	(a, b, c, n) = [int(x) for x in input().split()]
	m = max([a, b, c])
	N = m * 3 - a - b - c
	if N > n:
		print('NO')
	elif (N - n) % 3 == 0:
		print('YES')
	else:
		print('NO')


def solveA(a):
	(a, n) = (a[:-1], a[-1])
	m = max(a)
	if n == 0:
		print('YES' if a[0] == a[1] and a[1] == a[2] else 'NO')
		return
	if m == 0:
		print('YES' if n % 3 == 0 else 'NO')
		return
	t = sum([m - i for i in a])
	if n < t:
		print('NO')
		return
	t = n - t
	print('YES' if t % 3 == 0 else 'NO')
t = int(input())
while t > 0:
	t -= 1
	solveA([int(i) for i in input().split()])


t = int(input())
for i in range(t):
	(a, b, c, n) = map(int, input().split())
	A = [a, b, c]
	A.sort()
	B = A[2] - A[1]
	A = A[2] - A[0]
	n = n - A - B
	if (n % 3 == 0 or n == 0) and n >= 0:
		print('YES')
	else:
		print('NO')


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


for case in range(int(input())):
	s = list(map(int, input().split()))
	print('YES' if sum(s) % 3 == 0 and sum(s) // 3 >= max(s[:3]) else 'NO')


t = int(input())
for _ in range(t):
	(a, b, c, d) = map(int, input().split())
	m = max(a, b, c)
	if a != b != c and d == 0:
		print('NO')
		continue
	diff1 = m - a
	diff2 = m - b
	diff3 = m - c
	sum1 = diff1 + diff2 + diff3
	d = d - sum1
	if d % 3 == 0 and d >= 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	arr = [a, b, c, n] = list(map(int, input().split()))
	abc = arr[:3]
	if sum(arr) % 3 != 0 or 3 * max(abc) - sum(abc) > n:
		print('NO')
	else:
		print('YES')


def find(l, n):
	if l[0] != l[1]:
		k = l[1] - l[0]
		if n < k:
			return 'NO'
		else:
			n -= k
			l[0] += k
	if l[1] != l[2]:
		k = l[2] - l[1]
		a = k * 2
		if n < a:
			return 'NO'
		else:
			n -= a
			(l[0], l[1]) = (l[0] + k, l[1] + k)
	if n % 3 == 0:
		return 'YES'
	else:
		return 'NO'
a = int(input())
for _ in range(a):
	(a, b, c, n) = map(int, input().split())
	l = [a, b, c]
	l.sort()
	m = find(l, n)
	print(m)


qtd = int(input())
for i in range(qtd):
	(A, B, C, N) = map(int, input().split(' '))
	maior = max(A, B, C)
	aux = maior - A + (maior - B) + (maior - C)
	if N >= aux and (N - aux) % 3 == 0:
		print('YES')
	else:
		print('NO')


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


k = int(input())
for i in range(k):
	(a, b, c, n) = map(int, input().split())
	(a, b, c) = sorted([a, b, c])
	if ((a + b + c + n) % 3 == 0) & (abs(c - b) + abs(c - a) <= n):
		print('YES')
	else:
		print('NO')
	i += 1


t = int(input())
for r in range(t):
	(a, b, c, n) = map(int, input().split())
	maxi = max([a, b, c])
	maxidiff = 3 * maxi - (a + b + c)
	if n >= maxidiff and (n - maxidiff) % 3 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
while t:
	(a, b, c, n) = input().split()
	a = int(a)
	b = int(b)
	c = int(c)
	n = int(n)
	sum = a + b + c + n
	if sum % 3 != 0 or sum / 3 < a or sum / 3 < b or (sum / 3 < c):
		print('no')
	else:
		print('yes')
	t -= 1


import copy
n = int(input())
l = []
for i in range(n):
	temp = []
	inp = input().split(' ')
	for j in inp:
		temp.append(int(j))
	l.append(temp)
for i in l:
	ll = copy.copy(i[:3])
	ll.sort()
	c = i[3] - (2 * ll[2] - ll[1] - ll[0])
	if c < 0 or c % 3 != 0:
		print('NO')
	else:
		print('YES')


def test(a, b, c, n):
	ans = max(a, b, c)
	sum = ans - a + (ans - b) + (ans - c)
	n = n - sum
	if n < 0:
		return 'NO'
	if n % 3 == 0:
		return 'YES'
	else:
		return 'NO'
n = int(input())
for i in range(0, n):
	(a, b, c, n) = input().split()
	sum = 0
	a = int(a)
	b = int(b)
	c = int(c)
	n = int(n)
	s = test(a, b, c, n)
	print(s)


import sys

def get_ints():
	return map(int, sys.stdin.readline().strip().split())
t = int(input())
for x in range(t):
	(a, b, c, n) = get_ints()
	maxCoins = max(a, b, c)
	distCoins = 3 * maxCoins - (a + b + c)
	if n >= distCoins and (n - distCoins) % 3 == 0:
		print('YES')
	else:
		print('NO')


def a():
	g = [int(i) for i in input().split()]
	g1 = g[0:3]
	n = g[-1]
	g1.sort()
	if g1[0] == g1[1] == g1[2]:
		if n % 3 == 0:
			return 'YES'
	if g1[1] == g1[2] and g1[0] != g1[1]:
		quant = n - (g1[2] - g1[0])
		if quant >= 0 and quant % 3 == 0:
			return 'YES'
	if g1[1] == g1[0] and g1[2] != g1[1]:
		quant = n - 2 * (g1[2] - g1[0])
		if quant >= 0 and quant % 3 == 0:
			return 'YES'
	if g1[0] != g1[1] and g1[1] != g1[2]:
		quant = n - (g1[2] - g1[0]) - (g1[2] - g1[1])
		if quant >= 0 and quant % 3 == 0:
			return 'YES'
	return 'NO'
t = int(input())
for i in range(t):
	print(a())


num_cases = int(input())
for _ in range(num_cases):
	arr = [int(num) for num in input().split()]
	if sum(arr) % 3 != 0:
		print('NO')
	else:
		temp = sum(arr) // 3
		temp1 = True
		for i in range(3):
			if arr[i] > temp:
				temp1 = False
		if temp1:
			print('YES')
		else:
			print('NO')


t = int(input())
for i in range(t):
	inp = input().split()
	A = [int(e) for e in inp]
	s = sum(A)
	a = A[0]
	b = A[1]
	c = A[2]
	if s % 3 != 0 or (s % 3 == 0 and s / 3 < max(a, max(b, c))):
		print('NO')
	else:
		print('YES')


def ongko(a, b, c, n):
	lst = [a, b, c, n]
	lst1 = [a, b, c]
	lst1.sort(reverse=True)
	x = lst1[0]
	y = lst1[1]
	z = lst1[2]
	count = x - y + (x - z)
	ashol = n - count
	if ashol >= 0:
		if ashol % 3 == 0:
			z = 'YES'
		else:
			z = 'NO'
	else:
		z = 'NO'
	return z
t = int(input())
lst = list()
for i in range(t):
	data = input()
	data = data.split()
	a = int(data[0])
	b = int(data[1])
	c = int(data[2])
	n = int(data[3])
	lst.append(ongko(a, b, c, n))
for k in lst:
	print(k)


for t in range(int(input())):
	(a, b, c, n) = [int(i) for i in input().split()]
	m = max(a, b, c)
	ans = 'YES'
	ost = n - (m - a + m - b + m - c)
	if ost < 0:
		ans = 'NO'
	elif sum([int(i) for i in str(ost)]) % 3 != 0:
		ans = 'NO'
	print(ans)


import sys
input = sys.stdin.readline

def inp():
	return int(input())

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

def insr():
	s = input()
	return list(s[:len(s) - 1])

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

def main():
	t = int(inp())
	answer = []
	for i in range(t):
		(a, b, c, n) = inlt()
		flag = True
		if (a + b + c + n) % 3 != 0:
			flag = False
			answer.append('NO')
		else:
			target = (a + b + c + n) // 3
			if target - a < 0 or target - b < 0 or target - c < 0:
				answer.append('NO')
			else:
				answer.append('YES')
	print(*answer, sep='\n')
main()


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


from sys import stdin

def solve():
	pass

def lc():
	return [int(i) for i in stdin.readline().split()]
t = int(stdin.readline())
while t:
	(a, b, c, n) = lc()
	print('YES' if (n - a - a + b + c) % 3 == 0 and (n - a - a + b + c) // 3 >= 0 and ((n - b - b + a + c) % 3 == 0) and ((n - b - b + a + c) // 3 >= 0) and ((n - c - c + b + a) % 3 == 0) and ((n - c - c + b + a) // 3 >= 0) else 'NO')
	t -= 1


fast = lambda : stdin.readline().strip()
zzz = lambda : [int(i) for i in fast().split()]
(z, zz) = (input, lambda : list(map(int, z().split())))
(szz, graph, mod, szzz) = (lambda : sorted(zz()), {}, 10 ** 9 + 7, lambda : sorted(zzz()))
from re import *
from sys import *
from math import *
from heapq import *
from queue import *
from bisect import *
from string import *
from itertools import *
from collections import *
from math import factorial as f
from bisect import bisect as bs
from bisect import bisect_left as bsl
from collections import Counter as cc
from itertools import accumulate as ac

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def output(answer):
	stdout.write(str(answer))
num = int(z())
for _ in range(num):
	(a, b, c, n) = zzz()
	lst = [a, b, c]
	lst = sorted(lst)
	t = lst[2] - lst[0]
	if t <= n:
		lst[0] += t
		n -= t
	t = lst[2] - lst[1]
	if t <= n:
		lst[1] += t
		n -= t
	if n % 3 == 0 and len(set(lst)) == 1:
		print('YES')
	else:
		print('NO')


t = int(input())
for test in range(t):
	FLAG = 0
	(a, b, c, n) = [int(x) for x in input().split()]
	m = max(a, b, c)
	delta = 0
	delta += m - a
	delta += m - b
	delta += m - c
	if n - delta >= 0:
		if (n - delta) % 3 == 0:
			FLAG = 1
			print('YES')
	if FLAG == 0:
		print('NO')


import sys
input = lambda : sys.stdin.readline().strip()
for _ in ' ' * int(input()):
	(a, b, c, n) = list(map(int, input().split()))
	maxx = max(a, b, c)
	minn = min(a, b, c)
	l = []
	l.append(a)
	l.append(b)
	l.append(c)
	l.sort()
	n = n - (l[-1] - l[0])
	n = n - (l[-1] - l[1])
	if n < 0:
		print('NO')
	else:
		print('YES' if n % 3 == 0 else 'NO')


import sys
numcases = int(input())
count = 0
while count < numcases:
	isMax = False
	isDiv = False
	count += 1
	array = input().split(' ')
	for (i, val) in enumerate(array):
		array[i] = int(val)
	maxCoins = max(array[0], array[1], array[2])
	sistersTotal = array[0] + array[1] + array[2]
	if maxCoins * 3 - sistersTotal <= array[3]:
		isMax = True
	if (sistersTotal + array[3]) % 3 == 0:
		isDiv = True
	if isMax and isDiv:
		print('YES')
	else:
		print('NO')


kl = int(input())
for l in range(kl):
	(a, b, c, n) = [int(i) for i in input().split()]
	if (a + b + c + n) % 3 == 0 and max(a, b, c) <= (a + b + c + n) // 3:
		print('YES')
	else:
		print('NO')


size = int(input())
for i in range(size):
	ls = list(map(int, input().split()))
	coin = ls[-1]
	ls = ls[0:3]
	ls.sort()
	a = ls[2] - ls[0]
	b = ls[2] - ls[1]
	sb = coin - (a + b)
	if sb < 0 or sb % 3 != 0:
		print('NO')
	elif sb % 3 == 0 or sb == 0:
		print('YES')


for _ in range(int(input())):
	(a, b, c, n) = list(map(int, input().split()))
	z = max(a, b, c)
	sum = z - a + (z - b) + (z - c)
	if (n - sum) % 3 == 0 and n >= sum:
		print('Yes')
	else:
		print('No')


t = 1
results = []
if t >= 1 and t <= 10 ** 4:
	t = int(input())
for i in range(1, t + 1):
	(a, b, c, d) = [int(x) for x in input().split()]
	myList = [a, b, c]
	sum = a + b + c + d
	largest = max(myList)
	sumOfDif = largest - a + (largest - b) + (largest - c)
	if sum % 3 == 0 and d >= sumOfDif:
		results.append('YES')
	else:
		results.append('NO')
for result in results:
	print(result)


num = int(input())
while num != 0:
	s = input()
	l = s.split(' ')
	l = [int(x) for x in l]
	a = l[0]
	b = l[1]
	c = l[2]
	n = l[3]
	max_num = max(max(a, b), c)
	a = max_num - a
	b = max_num - b
	c = max_num - c
	left = n - (a + b + c)
	if left % 3 != 0 or left < 0:
		print('NO')
	else:
		print('YES')
	num -= 1


import sys
import os
import math
import copy
from math import gcd
from bisect import bisect
from io import BytesIO, IOBase
from math import sqrt, floor, factorial, gcd, log, ceil
from collections import deque, Counter, defaultdict
from itertools import permutations, combinations
import itertools

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

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

def Lstr():
	return list(sys.stdin.readline().strip())

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

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

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

def Hash():
	return dict()

def Mod():
	return 1000000007

def Ncr(n, r, p):
	return fact[n] * (ifact[r] * ifact[n - r] % p) % p

def Most_frequent(list):
	return max(set(list), key=list.count)

def Mat2x2(n):
	return [List() for _ in range(n)]

def solution():
	for i in range(Int()):
		(a, b, c, t) = Mint()
		s = 0
		m = max(a, b, c)
		s = m - a + (m - b) + (m - c)
		if s > t:
			print('NO')
		elif (t - s) % 3 == 0:
			print('YES')
		else:
			print('NO')
solution()


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


n = int(input())

def sum(L):
	s = 0
	for i in L:
		s += int(i)
	return s

def maxs(L):
	max = 0
	for i in range(0, len(L) - 1):
		if int(L[i]) > max:
			max = int(L[i])
	return max
for i in range(n):
	L = input().split(' ')
	if sum(L) % 3 == 0 and maxs(L) <= sum(L) // 3:
		print('YES')
	else:
		print('NO')


from sys import stdin
n = int(stdin.readline().rstrip())
for _ in range(n):
	(a, b, c, nC) = map(int, stdin.readline().rstrip().split(' '))
	nums = [a, b, c]
	nums.sort()
	t_dist = nums[-1] - nums[1] + (nums[-1] - nums[0])
	if nC >= t_dist and (nC - t_dist) % 3 == 0:
		print('YES')
	else:
		print('NO')


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


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


test_cases = int(input())
for i in range(test_cases):
	(a, b, c, n) = map(int, input().split())
	total = a + b + c + n
	max_coins = max(a, b, c)
	diff = max_coins - a + max_coins - b + max_coins - c
	if a > total // 3 or b > total // 3 or c > total // 3 or ((n - diff) % 3 != 0):
		print('NO')
	else:
		print('YES')


gi = lambda : list(map(int, input().split()))
(t,) = gi()
for k in range(t):
	(a, b, c, n) = gi()
	(a, b, c) = sorted([a, b, c])
	n -= 2 * c - b - a
	if n < 0 or n % 3:
		print('NO')
	else:
		print('YES')


ans = []
for _ in range(int(input())):
	coin = [int(x) for x in input().split()]
	n = coin[3]
	del coin[3]
	(a, b, c) = sorted(coin)
	need = 2 * c - a - b
	if n < need or (n - need) % 3:
		ans.append('NO')
	else:
		ans.append('YES')
print('\n'.join(ans))


t = int(input())
for x in range(1, t + 1):
	m = input()
	arr = m.split()
	a = int(arr[0])
	b = int(arr[1])
	c = int(arr[2])
	n = int(arr[3])
	if a >= b and a >= c:
		maxi = a
	if b >= a and b >= c:
		maxi = b
	if c >= a and c >= b:
		maxi = c
	if a <= b and a <= c:
		mini = a
	if b <= a and b <= c:
		mini = b
	if c <= a and c <= b:
		mini = c
	if a >= b and a <= c or (a <= b and a >= c):
		mid = a
	if b <= a and b >= c or (b >= a and b <= c):
		mid = b
	if c <= a and c >= b or (c >= a and c <= b):
		mid = c
	A = int(maxi - mini)
	B = int(maxi - mid)
	if mid + (n - (maxi - mini)) >= maxi:
		if (n - (A + B)) % 3 == 0 and int(mini) + A == int(mid) + B:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(a, b, c, n) = map(int, input().split())
	liste = [a, b, c]
	maxe = max(a, b, c)
	sume = 0
	for j in range(3):
		if liste[j] != maxe:
			sume += maxe - liste[j]
	if sume <= n:
		diff = n - sume
		if diff % 3 == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


n = int(input())
s = 0
lst = []
for i in range(n):
	s = 0
	lst = []
	n1 = list(map(int, input().split()))
	lst.append(n1[0])
	lst.append(n1[1])
	lst.append(n1[2])
	m = max(lst)
	for j in lst:
		c = m - j
		s = s + c
	w = n1[3] - s
	if w < 0:
		print('NO')
	else:
		x = w / 3
		b = str(x).split('.')
		if int(b[1]) != 0:
			print('NO')
		else:
			print('YES')


n = int(input())
for i in range(n):
	x = list(map(int, input().split()))
	if sum(x) % 3 == 0:
		mean = sum(x) // 3
		flag = True
		for i in range(3):
			if x[i] > mean:
				flag = False
		if flag:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


t = int(input())
while t:
	t -= 1
	lst = list(map(int, input().split()))
	(a, b, c, n) = (lst[0], lst[1], lst[2], lst[3])
	A = (b + c + n - 2 * a) / 3
	B = a + A - b
	C = n - A - B
	if A < 0 or A.is_integer() == False or B < 0 or (B.is_integer() == False) or (C < 0) or (C.is_integer() == False):
		print('NO')
	else:
		print('YES')


t = int(input())
for i in range(t):
	(a, b, c, n) = input().split()
	if int(a) >= int(b) and int(a) >= int(c):
		lar = int(a)
	elif int(b) >= int(a) and int(b) >= int(c):
		lar = int(b)
	else:
		lar = int(c)
	if lar == int(a):
		s = int(a) - int(b) + (int(a) - int(c))
	if lar == int(b):
		s = int(b) - int(a) + (int(b) - int(c))
	if lar == int(c):
		s = int(c) - int(a) + (int(c) - int(b))
	if s > int(n):
		print('NO')
	if s == int(n):
		print('Yes')
	if s < int(n):
		n = int(n) - s
		if int(n) % 3 == 0:
			print('Yes')
		else:
			print('NO')


t = int(input())
A = []

def Input():
	(a, b, c, n) = map(int, input().split())
	max = 0
	count = 0
	if a >= b:
		if a >= c:
			max = a
		else:
			max = c
	elif b >= c:
		max = b
	else:
		max = c
	count = max - b + (max - c) + (max - a)
	if n - count >= 0:
		if (n - count) % 3 == 0:
			A.append('YES')
		else:
			A.append('NO')
	else:
		A.append('NO')
for i in range(t):
	Input()
for i in range(t):
	print(A[i])


def func(a, b, c, n):
	x = max(a, b, c)
	y = 3 * x - (a + b + c)
	if n >= y and abs(n - y) % 3 == 0:
		return 'YES'
	return 'NO'
T = int(input())
while T > 0:
	(a, b, c, n) = map(int, input().split())
	print(func(a, b, c, n))
	T -= 1


n = int(input())
for i in range(n):
	abcn = list(map(int, input().split()))
	a = abcn[0]
	b = abcn[1]
	c = abcn[2]
	n = abcn[3]
	abc = [a, b, c]
	abc.sort(reverse=True)
	n = n - (abc[0] - abc[1]) - (abc[0] - abc[2])
	if n < 0:
		print('NO')
	elif n % 3 == 0:
		print('YES')
	else:
		print('NO')


for s in [*open(0)][1:]:
	s = list(map(int, s.split()))
	a = sum(s)
	if a % 3 == 0:
		a = a / 3
		if abs(a - s[0]) + abs(a - s[1]) + abs(a - s[2]) == s[-1]:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


def main():
	t = int(input())
	for i in range(t):
		s = input().split(' ')
		(a, b, c, n) = (int(s[0]), int(s[1]), int(s[2]), int(s[3]))
		if has_integer_solution(a, b, c, n):
			print('YES')
		else:
			print('NO')

def has_integer_solution(a, b, c, n):
	(A, B, C) = ((-2 * a + b + c + n) / 3, (a - 2 * b + c + n) / 3, (a + b - 2 * c + n) / 3)
	if A < 0 or B < 0 or C < 0:
		return False
	if (-2 * a + b + c + n) % 3 != 0:
		return False
	if (a - 2 * b + c + n) % 3 != 0:
		return False
	if (a + b - 2 * c + n) % 3 != 0:
		return False
	return True
main()


def prog():
	(a, b, c, d) = map(int, input().split())
	e = 3 * max(a, b, c) - a - b - c
	if (d - e) % 3 == 0 and d - e >= 0:
		print('YES')
	else:
		print('NO')
s = int(input())
for i in range(s):
	prog()


for _ in range(int(input())):
	(a, b, c, n) = list(map(int, input().split()))
	j = max(a, b, c)
	t = 3 * j - (a + b + c)
	n = n - t
	if n < 0:
		print('NO')
	elif n % 3 == 0:
		print('YES')
	else:
		print('NO')


qtd_vezes = int(input())
for _ in range(qtd_vezes):
	(a, b, c, n) = map(int, input().split())
	lista = [a, b, c]
	maior = max(lista)
	diferenca = maior * 3 - sum(lista)
	if diferenca > 0:
		if (n - diferenca) % 3 == 0 and n >= diferenca:
			print('YES')
		else:
			print('NO')
	if diferenca == 0:
		if a == b == c and n % 3 == 0:
			print('YES')
		else:
			print('NO')


t = int(input())
while t:
	arr = list(map(lambda x: int(x), input().split()))
	maxV = max(arr[0], max(arr[1], arr[2]))
	req = maxV - arr[0] + (maxV - arr[1]) + (maxV - arr[2])
	if req > arr[3]:
		print('NO')
	elif (arr[3] - req) % 3 == 0:
		print('YES')
	else:
		print('NO')
	t -= 1


T = int(input())
for _ in range(T):
	(a, b, c, n) = map(int, input().split())
	if (a + b + c + n) % 3 != 0:
		print('NO')
	else:
		avg = (a + b + c + n) // 3
		A = abs(avg - a)
		B = abs(avg - b)
		C = abs(avg - c)
		if A + B + C == n:
			print('yes')
		else:
			print('nO')


def main():

	def solve():
		(a, b, c, n) = map(int, input().split())
		if (a + b + c + n) % 3 != 0:
			print('NO')
		else:
			m = (a + b + c + n) // 3
			if m < a or m < b or m < c:
				print('NO')
			else:
				print('YES')
	q = int(input())
	for _ in range(q):
		solve()
main()


t = int(input())
for _ in range(t):
	l = list(map(int, input().split()))
	l2 = []
	for i in range(len(l) - 1):
		l2.append(l[i])
	l2.sort()
	l[3] -= 2 * l2[2] - l2[0] - l2[1]
	if l[3] < 0 or l[3] % 3 != 0:
		print('NO')
	else:
		print('YES')


test_cases = int(input())
cases = []
current_case = []
available_coins = 0
CanBeDone = True
for i in range(test_cases):
	cases.append(input())
for b in range(len(cases)):
	current_case = cases[b].split()
	for i in range(len(current_case)):
		current_case[i] = int(current_case[i])
	CanBeDone = True
	available_coins = current_case[3]
	current_case.remove(current_case[3])
	current_case.sort(reverse=True)
	diffrence = current_case[0] - current_case[1]
	available_coins -= diffrence
	if available_coins < 0:
		CanBeDone = False
	else:
		CanBeDone = True
	diffrence = current_case[0] - current_case[2]
	available_coins -= diffrence
	if available_coins < 0:
		CanBeDone = False
	else:
		CanBeDone = True
	if CanBeDone:
		if available_coins % 3 == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


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


a = int(input())
for i in range(a):
	(z, x, c, v) = map(int, input().split())
	ma = max(z, max(x, c))
	w = z + x + c + v
	if w % 3 == 0 and w / 3 >= ma:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(a, b, c, n) = map(int, input().split())
	r = max(a, b, c)
	s = [a, b, c]
	s.sort()
	n = n - 2 * r + s[0] + s[1]
	if n < 0 or n % 3:
		print('NO')
	else:
		print('YES')


t = int(input())
while t:
	l = list(map(int, input().split()))
	if sum(l) % 3 == 0 and max(l[0], l[1], l[2]) <= sum(l) / 3:
		print('YES')
	else:
		print('NO')
	t = t - 1


def f(a):
	c = sum(a)
	if c % 3 != 0:
		return 'NO'
	elif c % 3 == 0:
		k = c / 3
		if a[0] > k or a[1] > k or a[2] > k:
			return 'NO'
		else:
			return 'YES'
t = int(input())
for i in range(t):
	d = list(map(int, input().split(' ')))
	print(f(d))


for i in range(int(input())):
	l = list(map(int, input().split()))
	maxx = max(l[0:3])
	l[3] -= maxx - l[0] + (maxx - l[1]) + (maxx - l[2])
	if l[3] % 3 != 0 or l[3] < 0:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	(a, b, c, n) = map(int, input().split())
	p = [0] * 3
	p[0] = a
	p[1] = b
	p[2] = c
	p.sort(reverse=True)
	req = n - (p[0] - p[1] + p[0] - p[2])
	if req % 3 == 0 and req >= 0:
		print('YES')
	else:
		print('NO')


t = int(input())
while t > 0:
	(a, b, c, p) = map(int, input().split())
	l = [a, b, c]
	maxi = l.index(max(l))
	resultsum = 0
	for i in range(3):
		if i != maxi:
			resultsum += l[maxi] - l[i]
	if p - resultsum >= 0 and (p - resultsum) % 3 == 0:
		print('YES')
	else:
		print('NO')
	t -= 1


import math
for _ in range(int(input())):
	(a, b, c, n) = map(int, input().split())
	a1 = sorted([a, b, c])
	d = a1[2] - a1[1] + (a1[2] - a1[0])
	n = n - d
	if n < 0:
		print('NO')
		continue
	if n % 3 == 0:
		print('YES')
	else:
		print('NO')


T = input()
T = int(T)
for i in range(T):
	a = []
	a = [int(i) for i in input().split()]
	N = a[3]
	a = sorted(a[:-1])[::-1]
	delta = 2 * a[0] - a[1] - a[2]
	if delta > N:
		print('NO')
		continue
	if (N - delta) % 3 != 0:
		print('NO')
		continue
	print('YES')


n = int(input())
for i in range(n):
	t = [int(num) for num in input().split()]
	s = t[:-1]
	max_s = max(s)
	diff = t[3] - (3 * max_s - sum(s))
	if diff % 3 == 0 and diff >= 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(a, b, c, n) = map(int, input().split())
	all_coins = a + b + c + n
	if all_coins % 3 != 0:
		print('NO')
	else:
		one_coin = all_coins // 3
		if one_coin - a < 0 or one_coin - b < 0 or one_coin - c < 0:
			print('NO')
		else:
			print('YES')


import math
t = int(input())
while t > 0:
	(a, b, c, n) = map(int, input().split())
	List = [a, b, c]
	List.sort()
	coinsRequired = 2 * List[2] - List[0] - List[1]
	remainingCoins = n - coinsRequired
	if n >= coinsRequired and remainingCoins % 3 == 0:
		print('YES')
	else:
		print('NO')
	t -= 1


t = int(input())
for i in range(t):
	x = list(map(int, input().strip().split()))
	y = max(x[:3])
	z = abs(3 * y - x[0] - x[1] - x[2])
	w = x[3] - z
	if z > x[3]:
		print('NO')
	elif w % 3 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
while t:
	(a, b, c, n) = map(int, input().strip().split())
	final_coins = (a + b + c + n) / 3
	if (a + b + c + n) % 3 == 0:
		if a > final_coins or b > final_coins or c > final_coins:
			print('NO')
		else:
			print('YES')
	else:
		print('NO')
	t -= 1


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


t = int(input())
for _ in range(t):
	a = [int(x) for x in input().split(' ')]
	sum = a[0] + a[1] + a[2] + a[3]
	if sum % 3 == 0 and sum / 3 - a[0] >= 0 and (sum / 3 - a[1] >= 0) and (sum / 3 - a[2] >= 0):
		print('YES')
	else:
		print('NO')


t = int(input())
while t:
	t -= 1
	(a, b, c, n) = map(int, input().split())
	m = max([a, b, c])
	s = 0
	for x in [a, b, c]:
		if x == m:
			continue
		s += m - x
	if n - s >= 0 and (n - s) % 3 == 0:
		print('YES')
	else:
		print('NO')


n = int(input())
while n > 0:
	(x, y, z, t) = map(int, input().split())
	m = []
	m.append(x)
	m.append(y)
	m.append(z)
	m.sort(reverse=True)
	A = max(m)
	t = t - (A - m[1])
	t = t - (A - m[2])
	if t < 0:
		print('NO')
	elif t % 3 == 0:
		print('YES')
	else:
		print('NO')
	n -= 1


num = int(input())
mas = [None] * num
for i in range(num):
	mas[i] = list(map(int, input().split()))
for i in range(num):
	cur = sorted(mas[i][:3])[::-1]
	p = mas[i][-1]
	if (p - 2 * cur[0] + cur[1] + cur[2]) % 3 == 0 and p >= 2 * cur[0] - cur[1] - cur[2]:
		print('YES')
	else:
		print('NO')


from collections import Counter
from collections import defaultdict
import math
import random
import heapq as hq
from math import sqrt
import sys

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

def iinput():
	return int(input())

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

def rinput():
	return map(int, tinput())

def rlinput():
	return list(rinput())
mod = int(1000000000.0) + 7

def solve(adj, colors, n):
	pass

def root(parent, a):
	while parent[a] != a:
		parent[a] = parent[parent[a]]
		a = parent[a]
	return a

def union(parent, size, a, b):
	(roota, rootb) = (root(parent, a), root(parent, b))
	if roota == rootb:
		return
	parent[rootb] = roota
	size[roota] += size[rootb]
	size[rootb] = 0
for _ in range(iinput()):
	(a, b, c, n) = rinput()
	temp = a + b + c + n
	if temp % 3 != 0:
		print('NO')
	else:
		temp = temp / 3
		if temp < a or temp < b or temp < c:
			print('NO')
		else:
			print('YES')


import os, sys
from io import BytesIO, IOBase

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

def si():
	return input()

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

def li():
	return list(mi())
import math
for i in range(ii()):
	(a, b, c, n) = mi()
	s = a + b + c + n
	if s % 3 == 0 and max(a, b, c) <= s // 3:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	a = list(map(int, input().split()))
	f = max(a[:3]) * 3
	s = sum(a[:3])
	ans = f - s
	a[3] = a[3] - ans
	ans = a[3]
	if ans < 0 or ans % 3 != 0:
		print('NO')
	else:
		print('YES')


def solve(a, b, c, n, ans):
	A = n - 2 * a + b + c
	if A % 3 != 0:
		ans.append('NO')
		return
	A = A // 3
	B = A + a - b
	C = A + a - c
	if A < 0 or B < 0 or C < 0:
		ans.append('NO')
		return
	ans.append('YES')

def main():
	t = int(input())
	ans = []
	for i in range(t):
		(a, b, c, n) = map(int, input().split())
		solve(a, b, c, n, ans)
	for i in ans:
		print(i)
main()


for i in range(int(input())):
	l = list(map(int, input().split()))
	y = sum(l)
	k = y // 3
	if y % 3 == 0 and k >= max(l[0], l[1], l[2]):
		print('YES')
	else:
		print('NO')


import sys
t = int(input())
for i in range(t):
	(a, b, c, n) = map(int, input().split())
	if (a + b + c + n) % 3 == 0 and a <= (a + b + c + n) // 3 and (b <= (a + b + c + n) // 3) and (c <= (a + b + c + n) // 3):
		print('YES')
	else:
		print('NO')


T = int(input())
for _ in range(T):
	(a, b, c, n) = map(int, input().split())
	anchor = max(a, b, c)
	compensation = 0
	for i in (a, b, c):
		if anchor == i:
			pass
		else:
			compensation += anchor - i
	n -= compensation
	if n < 0:
		print('NO')
	elif n % 3 == 0:
		print('YES')
	else:
		print('NO')


def solve():
	(a, b, c, n) = map(int, input().split())
	A = n + b + c - 2 * a
	B = n + a + c - 2 * b
	C = n + a + b - 2 * c
	if A < 0 or B < 0 or C < 0 or (A % 3 != 0) or (B % 3 != 0) or (C % 3 != 0):
		return 'NO'
	else:
		return 'YES'
for _ in range(int(input())):
	print(solve())


import sys
t = int(sys.stdin.readline().rstrip())
for _ in range(t):
	(a, b, c, n) = list(map(int, sys.stdin.readline().rstrip().split(' ')))
	tem = max(a, b, c)
	tem = tem - a + tem - b + tem - c
	if n < tem:
		print('NO')
	elif (n - tem) % 3 == 0:
		print('YES')
	else:
		print('NO')


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


for _ in [*open(0)][1:]:
	(a, b, c, n) = map(int, _.split())
	print(['NO', 'YES'][(a + b + c + n) % 3 == 0 and (a + b + c + n) // 3 - a >= 0 and ((a + b + c + n) // 3 - b >= 0) and ((a + b + c + n) // 3 - c >= 0)])


t = int(input())
for i in range(t):
	(a, b, c, d) = map(int, input().split())
	avg = (a + b + c + d) / 3
	per_max = max(a, b, c)
	if (a + b + c + d) % 3 != 0 or per_max > avg:
		print('NO')
	else:
		print('YES')


t = int(input(''))
for i in range(0, t):
	s = input('')
	l1 = [int(x) for x in s.split()]
	n = l1[len(l1) - 1]
	l1.pop()
	sum = 0
	for i in l1:
		sum += max(l1) - i
	if int(n - sum) % 3 == 0 and n - sum >= 0:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(a_, b_, c_, n) = map(int, input().split())
	(a, b, c) = list(sorted([a_, b_, c_]))
	r = c - b + (c - a)
	print('YES' if r <= n and (n - r) % 3 == 0 else 'NO')


while True:
	x = int(input(''))
	if 0 < x:
		break
l = list()
for i in range(x):
	while True:
		y = input('')
		m = y.split(' ')
		for j in range(len(m)):
			m[j] = int(m[j])
		if m[0] > 0 and m[1] > 0 and (m[2] > 0) and (m[3] >= 0):
			break
	l.append(m)
for i in range(x):
	s = 0
	p = 0
	n = 0
	p = l[i][0] + l[i][1] + l[i][2] + l[i][3]
	if p % 3 == 0:
		s += 1
	n = p / 3
	if n >= l[i][0] and n >= l[i][1] and (n >= l[i][2]):
		s += 1
	if s == 2:
		print('YES')
	else:
		print('NO')


t = int(input())
while t:
	one = list()
	(a, b, c, x) = input().split(' ')
	(a, b, c, x) = (int(a), int(b), int(c), int(x))
	one.append(a)
	one.append(b)
	one.append(c)
	one.sort(reverse=True)
	nc = 2 * one[0] - (one[1] + one[2])
	if nc > x:
		print('NO')
	elif (x - nc) % 3 == 0:
		print('YES')
	else:
		print('NO')
	t -= 1


def solve():
	maxi = max(a, b, c)
	rem = 3 * maxi - a - b - c
	return 'YES' if n >= rem and (n - rem) % 3 == 0 else 'NO'

def main():
	global a, b, c, n
	for _ in range(int(input())):
		(a, b, c, n) = list(map(int, input().split()))
		print(solve())
main()


t = int(input())
lst = []
for h in range(t):
	(aa, bb, cc, nn) = input().split()
	a = int(aa)
	b = int(bb)
	c = int(cc)
	n = int(nn)
	l = [a, b, c]
	l.sort()
	g = n - abs(l[0] - l[2])
	o = g - abs(l[1] - l[2])
	z = ''
	if o % 3 == 0 and o >= 0:
		z = 'YES'
	else:
		z = 'NO'
	lst.append(z)
for y in lst:
	print(y)


N = int(input())
for _ in range(N):
	(a, b, c, n) = map(int, input().split())
	lar = max(a, b, c)
	deficit = lar - a + (lar - b) + (lar - c)
	if n >= deficit and (n - deficit) % 3 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for x in range(0, t):
	ar = [int(i) for i in input().split()]
	a = ar[0]
	b = ar[1]
	c = ar[2]
	n = ar[3]
	maxx = max(max(a, b), c)
	total = maxx - a + (maxx - b) + (maxx - c)
	if (n - total) % 3 == 0 and n - total >= 0:
		print('YES')
	else:
		print('NO')


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


test_cases = int(input())
for _ in range(test_cases):
	(A, B, C, n) = map(int, input().split(' '))
	total = sum([A, B, C, n])
	if total % 3 > 0:
		print('NO')
		continue
	else:
		average = total / 3
		if A > average or B > average or C > average:
			print('NO')
			continue
		else:
			print('YES')
			continue


from __future__ import division, print_function
from collections import *
from math import *
from itertools import *
from time import time
import os
import sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def main():
	(a, b, c, n) = map(int, input().split())
	li = [a, b, c]
	big = 3 * max(li)
	sums = sum(li)
	difference = big - sums
	if n < difference:
		print('NO')
		return
	leftover = n - difference
	if leftover % 3 == 0:
		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')

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')
t = int(input())
while t:
	main()
	t -= 1


def distribute(a, b, c, n):
	m = max([a, b, c])
	r = m - a + (m - b) + (m - c)
	a = n - r
	if n < r:
		return -1
	else:
		return a

def coins(a, b, c, n):
	r = distribute(a, b, c, n)
	if r == -1:
		return 'NO'
	if r % 3 == 0:
		return 'YES'
	return 'NO'
t = int(input())
for i in range(t):
	l = []
	(a, b, c, n) = [int(x) for x in input().split()]
	print(coins(a, b, c, n))


tests = int(input())
while tests > 0:
	coins = [int(i) for i in input().split(' ')]
	n = coins.pop(-1)
	coins.sort()
	n = n - (coins[2] - coins[0]) - (coins[2] - coins[1])
	if n == 0 or (n > 0 and n % 3 == 0):
		print('YES')
	else:
		print('NO')
	tests = tests - 1


def main():
	N = int(input())
	arrays = []
	for _ in range(N):
		arrays.append([int(x) for x in input().split()])
	for i in range(len(arrays)):
		(A, B, C, T) = (arrays[i][0], arrays[i][1], arrays[i][2], arrays[i][3])
		max_ = max([A, B, C])
		A += max_ - A
		B += max_ - B
		C += max_ - C
		V = max_ - arrays[i][0] + (max_ - arrays[i][1]) + (max_ - arrays[i][2])
		T = T - V
		if T < 0:
			print('NO')
		elif T % 3 == 0:
			print('YES')
		else:
			print('NO')
main()


for _ in ' ' * int(input()):
	l = list(map(int, input().split()))
	print(['NO', 'YES'][sum(l) % 3 < 1 and max(l[:3]) <= sum(l) // 3])


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


n = int(input())
for k in range(n):
	z = 0
	s = 'NO'
	a = input().split()
	for i in range(len(a)):
		z += int(a[i])
	if z % 3 == 0 and int(a[0]) <= z // 3 and (int(a[1]) <= z // 3) and (int(a[2]) <= z // 3):
		s = 'YES'
	print(s)


def main():
	for _ in range(int(input())):
		(a, b, c, n) = map(int, input().split())
		x = max(a, b, c)
		req_coins = 3 * x - a - b - c
		if req_coins > n or (n - req_coins) % 3 != 0:
			print('NO')
		else:
			print('YES')
main()


queryes = int(input())
for q in range(queryes):
	(a, b, c, n) = map(int, input().split())
	l = max(a, b, c)
	need = l - a + (l - b) + (l - c)
	if need > n:
		print('NO')
		continue
	n -= need
	if n % 3 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for test in range(t):
	coins = [int(x) for x in input().split()]
	n = coins[3]
	coins = coins[:3]
	maxi = max(coins)
	want = [maxi - x for x in coins]
	want = sum(want)
	left = n - want
	if left >= 0 and left % 3 == 0:
		print('YES')
	else:
		print('NO')


import math
t = int(input())
for _ in range(t):
	(a, b, c, d) = map(int, input().split())
	A = []
	A.append(a)
	A.append(b)
	A.append(c)
	A.sort()
	ss = A[2] - A[1] + A[2] - A[0]
	ans = d - ss
	if ans >= 0 and ans % 3 == 0:
		print('YES')
	else:
		print('NO')


def solution(c):
	ans = []
	for i in range(0, len(c)):
		coin = c[i]
		n = coin[3]
		coin.pop(3)
		coin.sort()
		t = coin[2] - coin[1] + (coin[2] - coin[0])
		if n >= t:
			n = n - t
			if n % 3 == 0:
				ans.append('YES')
				continue
			else:
				ans.append('NO')
				continue
		else:
			ans.append('NO')
			continue
	return ans

def main():
	t = int(input())
	test = []
	for i in range(0, t):
		coins = list(map(int, input().split()))
		test.append(coins)
	result = solution(test)
	for j in range(0, len(result)):
		print(result[j])
main()


t = int(input())
for i in range(t):
	l = list(map(int, input().split()))
	n = l.pop(3)
	q = max(l)
	l.remove(q)
	w = q - l[0] + q - l[1]
	if n >= w and pow(n - w, 1, 3) == 0:
		print('Yes')
	else:
		print('No')


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


str = input()
Case = int(str)
for T in range(Case):
	str = input()
	s = str.split()
	a = int(s[0])
	b = int(s[1])
	c = int(s[2])
	n = int(s[3])
	sum = a + b + c + n
	if sum % 3 != 0:
		print('NO')
	else:
		average = sum // 3
		need = abs(a - average) + abs(b - average) + abs(c - average)
		if need <= n:
			print('YES')
		else:
			print('NO')


t = int(input())
ls = list()
for i in range(t):
	ls.append(list(map(int, input().split())))
for i in range(t):
	ls2 = ls[i]
	m = max(ls2[:3])
	for i in range(3):
		ls2[3] -= m - ls2[i]
	if ls2[3] < 0 or ls2[3] % 3:
		print('NO')
	else:
		print('YES')


t = int(input())
for i in range(0, t):
	(a, b, c, n) = map(int, input().split())
	numeritos = list()
	numeritos.append(a)
	numeritos.append(b)
	numeritos.append(c)
	numeritos.sort()
	a = numeritos[0]
	b = numeritos[1]
	c = numeritos[2]
	dif1 = c - a
	dif2 = c - b
	difTot = dif1 + dif2
	bandera1 = n - difTot
	if bandera1 < 0:
		print('NO')
	elif bandera1 == 0:
		print('YES')
	elif bandera1 % 3 == 0:
		print('YES')
	else:
		print('NO')


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


numTestcases = int(input())
for i in range(numTestcases):
	cLine = list(map(int, input().split(' ')))
	a = cLine[0]
	b = cLine[1]
	c = cLine[2]
	n = cLine[3]
	cMax = max(a, b, c)
	n -= cMax - a + cMax - b + cMax - c
	if n < 0:
		print('NO')
	elif n % 3 == 0:
		print('YES')
	else:
		print('NO')


cases = int(input())
for i in range(cases):
	coins = list(map(int, input().split()))
	N = coins[-1]
	coins.remove(N)
	max_deno = max(coins)
	k = max_deno * 3 - sum(coins)
	if N == k:
		print('YES')
	elif (N - k) % 3 == 0 and N > k:
		print('YES')
	else:
		print('NO')


import sys
import math
import bisect
import itertools
import random
import re

def solve(A, m):
	val = 0
	for a in A:
		val += max(A) - a
	if val > m:
		return False
	return (m - val) % 3 == 0

def main():
	for _ in range(int(input())):
		(a, b, c, n) = map(int, input().split())
		if solve([a, b, c], n):
			print('YES')
		else:
			print('NO')
main()


import math
from sys import stdin, stdout

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

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

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

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

def main():
	for i in range(I()):
		(a, b, c, n) = In()
		x = max(a, b, c)
		print('YES' if x - a + (x - b) + (x - c) <= n and (n - (x - a + (x - b) + (x - c))) % 3 == 0 else 'NO')
main()


for _ in range(int(input())):
	i = [int(i) for i in input().split()]
	c = [max(i[:3]) - j for j in i[:3]]
	n = i[3]
	if n - sum(c) >= 0 and (n - sum(c)) % 3 == 0:
		print('YES')
	else:
		print('NO')


import sys

def fastio():
	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 debug(*var, sep=' ', end='\n'):
	print(*var, file=sys.stderr, end=end, sep=sep)
INF = 10 ** 20
MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
from math import gcd
from math import ceil
from collections import defaultdict as dd, Counter
from bisect import bisect_left as bl, bisect_right as br
(t,) = I()
while t:
	t -= 1
	(a, b, c, n) = I()
	ans = 'YES'
	(a, b, c) = sorted([a, b, c])
	n -= c - a
	n -= c - b
	if n < 0 or n % 3:
		ans = 'NO'
	print(ans)


def max(a, b, c):
	if a >= b and a >= c:
		return a
	elif b >= a and b >= c:
		return b
	elif c >= a and c >= b:
		return c
for case in range(int(input())):
	(a, b, c, n) = map(int, input().split())
	x = max(a, b, c)
	d = x - a + (x - b) + (x - c)
	if d > n:
		print('NO')
	elif (n - d) % 3 == 0:
		print('YES')
	else:
		print('NO')


def f(a, b, c, n):
	r = a + b + c + n
	if r % 3 == 0:
		if r // 3 < a or r // 3 < b or r // 3 < c:
			return 'NO'
		else:
			return 'YES'
	else:
		return 'NO'
t = int(input())
while t > 0:
	t -= 1
	(a, b, c, n) = map(int, input().split())
	print(f(a, b, c, n))


T = int(input())
for _ in range(T):
	(a, b, c, n) = map(int, input().split())
	mx = max(a, b, c)
	tot = mx - a + mx - b + mx - c
	if n < tot:
		print('NO')
	else:
		n = n - tot
		if n % 3 == 0:
			print('YES')
		else:
			print('NO')


T = int(input())
for i in range(T):
	(a, b, c, n) = map(int, input().split())
	s = a + b + c + n
	if s % 3 == 0:
		f = 0
		m = s / 3
		if a > m or b > m or c > m:
			f = 1
		if f == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


n = int(input())
ar = list()
for i in range(n):
	ar += [[int(t) for t in input().split()][:4]]
for i in ar:
	avr = sum(i) / 3
	if sum(i) % 3 == 0 and avr >= i[0] and (avr >= i[1]) and (avr >= i[2]):
		print('Yes')
	else:
		print('NO')


test = int(input())
for _ in range(test):
	(a, b, c, n) = map(int, input().split())
	if (a + b + c + n) % 3 == 0:
		arr = [a, b, c]
		arr.sort()
		maxnum = abs(2 * arr[2] - arr[1] - arr[0])
		if maxnum <= n:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


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


import sys
read = sys.stdin.buffer.readline
for _ in range(int(read())):
	(a, b, c, n) = map(int, read().split())
	sm = n + a + b + c
	print(['no', 'yes'][sm % 3 == 0 and sm // 3 >= max(a, b, c)])


t = int(input())
for _ in range(t):
	arr = list(map(int, input().split()))
	if sum(arr) % 3 != 0:
		print('NO')
	else:
		n = arr[3]
		(a, b, c) = sorted(arr[:3])
		n = n - (c - b) - (c - a)
		if n < 0:
			print('NO')
		else:
			print('YES')


from collections import defaultdict, deque
from itertools import permutations
from sys import stdin, stdout
from bisect import bisect_left, bisect_right
from copy import deepcopy
int_input = lambda : int(stdin.readline())
string_input = lambda : stdin.readline()
multi_int_input = lambda : map(int, stdin.readline().split())
multi_input = lambda : stdin.readline().split()
list_input = lambda : list(map(int, stdin.readline().split()))
string_list_input = lambda : list(string_input())
MOD = pow(10, 9) + 7
test = int_input()
for _ in range(test):
	(a, b, c, n) = multi_int_input()
	if a == b and b == c and (n % 3 == 0):
		print('YES')
	else:
		maxi = 0
		if a >= b and a >= c:
			maxi = a
		elif b >= a and b >= c:
			maxi = b
		else:
			maxi = c
		diff = maxi - a + maxi - b + maxi - c
		n = n - diff
		if n < 0:
			print('NO')
		elif n % 3 == 0:
			print('YES')
		else:
			print('NO')


for _ in range(int(input())):
	(a, b, c, n) = map(int, input().split())
	M = sorted([a, b, c])
	top = M[-1]
	(B, C) = (M[0], M[1])
	need_more = top - B + top - C
	if n < need_more:
		print('NO')
	elif (n - need_more) % 3 != 0:
		print('NO')
	else:
		print('YES')


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


a = int(input())
for _ in range(a):
	arry = input()
	arrym = arry.split()
	for i2 in range(4):
		arrym[i2] = int(arrym[i2])
	arrym0 = [0] * 3
	for i in range(3):
		arrym0[i] = arrym[i]
	arrym0.sort(key=int, reverse=True)
	a1 = arrym0[0] - arrym0[1]
	a2 = arrym0[0] - arrym0[2]
	v = arrym[3] - a1 - a2
	if v >= 0 and v % 3 == 0:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	a = list(map(int, input().split()))
	total = sum(a) % 3
	answer = sum(a) // 3
	if total == 0:
		maximum = max(a[:-1])
		if maximum <= answer:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


t = int(input())
for i in range(t):
	ar = list(map(int, input().split()))
	n = ar[3]
	ar.pop(3)
	ar.sort()
	a = ar[2] - ar[0]
	b = ar[2] - ar[1]
	if a + b <= n:
		if (n - (a + b)) % 3 == 0:
			print('Yes')
		else:
			print('No')
	else:
		print('No')


l = []
n = int(input())
suum = 0
for i in range(0, n):
	(a, b, c, tt) = [int(x) for x in input().split()]
	tr = a + b + c + tt - 3 * max(a, b, c)
	if tr >= 0:
		if tr == 0 or tr % 3 == 0:
			l.append('YES')
		else:
			l.append('NO')
	else:
		l.append('No')
for i in l:
	print(i)


for _ in [0] * int(input()):
	(a, b, c, n) = map(int, input().split())
	max_ = max(a, b, c)
	(a1, a2, a3) = (abs(a - max_), abs(b - max_), abs(c - max_))
	if a1 + a2 + a3 > n:
		print('NO')
	else:
		a += a1
		b += a2
		c += a3
		n -= a1 + a2 + a3
		if n is not 0 and n % 3 is not 0:
			print('NO')
		else:
			print('YES')


t = int(input())
for x in range(t):
	(a, b, c, n) = map(int, input().split())
	d = max(a, b, c)
	h = d - a + (d - b) + (d - c)
	if h > n:
		print('NO')
	elif (n - h) % 3 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(a, b, c, n) = map(int, input().strip().split())
	raj = max(a, b, c)
	sub = raj - a + (raj - b) + (raj - c)
	n = n - sub
	if n % 3 != 0 or n < 0:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	(a, b, c, n) = map(int, input().split())
	m = max(a, b, c)
	new = m - a + m - b + m - c
	if a == b == c and n % 3 == 0:
		print('YES')
	elif a == b == c and n % 3 != 0:
		print('NO')
	elif (n - new) % 3 == 0 and n - new >= 0:
		print('YES')
	else:
		print('NO')


y = int(input())
st_list = []
for i in range(y):
	st_list.append(input())
for i in st_list:
	lst = i.split()
	lst = list(map(int, lst))
	n = lst.pop()
	if 3 * max(lst) - sum(lst) <= n and (n - (3 * max(lst) - sum(lst))) % 3 == 0:
		print('YES')
	else:
		print('NO')


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


T = int(input())

def coins(a, b, c, n):
	each = (a + b + c + n) / 3
	lst1 = [a, b, c]
	x = max(lst1)
	lst1.remove(max(lst1))
	if sum(lst1) + n >= 2 * x:
		if int(each) == each:
			return 'YES'
		else:
			return 'NO'
	else:
		return 'NO'
if 1 <= T <= 10 ** 4:
	lst = []
	while T != 0:
		(a, b, c, n) = input().split()
		lst.append((int(a), int(b), int(c), int(n)))
		T -= 1
	for (a, b, c, n) in lst:
		if 1 <= a <= 10 ** 8 and 1 <= b <= 10 ** 8 and (1 <= c <= 10 ** 8) and (1 <= n <= 10 ** 8):
			print(coins(a, b, c, n))
		else:
			print('NO')


t = int(input())
for _ in range(t):
	arr = list(map(int, input().split()))
	mx = max(arr[:-1])
	sm = sum((mx - a for a in arr[:-1]))
	if arr[-1] - sm >= 0 and (arr[-1] - sm) % 3 == 0:
		print('YES')
	else:
		print('NO')


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


n = input()
for i in range(int(n)):
	(a, b, c, d) = input().split(' ')
	a = int(a)
	b = int(b)
	c = int(c)
	d = int(d)
	sums = a + b + c + d
	if sums % 3 == 0:
		if sums / 3 < a or sums / 3 < b or sums / 3 < c:
			print('NO')
			continue
		print('YES')
		continue
	print('NO')


t = int(input())
for w in range(t):
	(a, b, c, n) = input().split(' ')
	a = int(a)
	b = int(b)
	c = int(c)
	n = int(n)
	if (a + b + c + n) % 3 != 0:
		print('NO')
		continue
	t = (a + b + c + n) // 3
	if a > t or b > t or c > t:
		print('NO')
		continue
	print('YES')


for _ in range(int(input())):
	L = list(map(int, input().split()))
	if sum(L) % 3 == 0 and max(L[0:3:1]) * 3 - sum(L[0:3:1]) <= L[-1]:
		print('YES')
	else:
		print('NO')
5


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


t = int(input())
for _ in range(t):
	(a, b, c, n) = [int(x) for x in input().split()]
	sum_coins = a + b + c + n
	average = sum_coins // 3
	if sum_coins % 3 == 0 and average >= a and (average >= b) and (average >= c):
		print('YES')
	else:
		print('NO')


import sys
input = sys.stdin.readline
for i in range(int(input())):
	(a, b, c, n) = map(int, input().split())
	d = a + b + c + n
	if d % 3 == 0:
		m = d // 3
		A = m - a
		B = m - b
		C = m - c
		if A >= 0 and B >= 0 and (C >= 0) and (A + B + C == n):
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


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

def rints():
	return list(map(int, input().split()))
t = rint()
for _ in range(t):
	(a, b, c, n) = rints()
	(a, b, c) = sorted([a, b, c])
	mn = c - a + c - b
	print('YES' if mn <= n and (n - mn) % 3 == 0 else 'NO')


t = int(input())
for i in range(t):
	(a, b, c, n) = map(int, input().split(' '))
	l = []
	l.append(a)
	l.append(b)
	l.append(c)
	l.sort(reverse=True)
	sum = 0
	sum = sum + (l[0] - l[1]) + (l[0] - l[2])
	if sum > n:
		print('NO')
	else:
		r = n - sum
		if r % 3 == 0:
			print('YES')
		else:
			print('NO')


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


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


t = int(input())
for _ in range(t):
	(a, b, c, n) = map(int, input().split())
	flag = 0
	if (a + b + c + n) % 3 == 0:
		e = (a + b + c + n) // 3
		if a > e or b > e or c > e:
			flag = 1
	else:
		flag = 1
	if flag == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(a, b, c, n) = map(int, input().split())
	numsn = [a, b, c, n]
	nums = [a, b, c]
	sumnum = sum(numsn)
	nums.sort()
	if n >= nums[2] - nums[1] + (nums[2] - nums[0]):
		if sumnum % 3 == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


for _ in range(int(input())):
	l = list(map(int, input().split()))
	n = l[-1]
	l = l[:-1]
	l.sort()
	n -= 2 * l[2] - l[1] - l[0]
	if n < 0 or n % 3 != 0:
		print('NO')
	else:
		print('YES')


t = int(input())
while t > 0:
	(a, b, c, n) = [int(c) for c in input().split(' ')]
	final = a + b + c + n
	if final % 3 != 0:
		print('NO')
	else:
		final = final // 3
		if final - a >= 0 and final - b >= 0 and (final - c >= 0):
			print('YES')
		else:
			print('NO')
	t -= 1


t = int(input())
for i in range(t):
	a = list(map(int, input().split()))
	n = a[-1]
	a.pop(3)
	a.sort()
	q = 2 * a[2] - a[0] - a[1]
	if q <= n:
		if (n - q) % 3 == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


n = int(input())
for i in range(n):
	p = list(map(int, input().split()))
	max_1 = max(p[0], p[1], p[2])
	p.remove(max_1)
	max_2 = max(p[0], p[1])
	p.remove(max_2)
	max_3 = p[0]
	a = max_1 - max_2
	p[1] = p[1] - a
	b = max_1 - max_3
	p[1] = p[1] - b
	if p[1] < 0 or p[1] % 3 != 0:
		print('NO')
	else:
		print('YES')


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


i = int(input())
l = []
for _ in range(i):
	s = 0
	(a, b, c, n) = [int(d) for d in input().split()]
	e = (a + b + c + n) / 3
	if a < e:
		s += e - a
	if b < e:
		s += e - b
	if c < e:
		s += e - c
	if (a + b + c + n) % 3 == 0 and s == n:
		l.append('YES')
	else:
		l.append('NO')
print(*l, sep='\n')


for _ in range(int(input())):
	nums = [int(x) for x in input().split()]
	n = nums.pop(-1)
	nums.sort()
	n -= 2 * nums[2] - nums[0] - nums[1]
	if n % 3 == 0 and n >= 0:
		print('YES')
	else:
		print('NO')


def handle(line):
	temp = line.split()
	a = int(temp[0])
	b = int(temp[1])
	c = int(temp[2])
	n = int(temp[3])
	return (a, b, c, n)

def simplify(a, b, c):
	temp = min([a, b, c])
	result = [a - temp, b - temp, c - temp]
	result.sort()
	return (result[0], result[1], result[2])

def solve(a, b, c, n):
	(a, b, c) = simplify(a, b, c)
	n -= b - a
	a = b
	if n < 0:
		return False
	(a, b, c) = simplify(a, b, c)
	n -= c - a
	a = c
	if n < 0:
		return False
	n -= c - b
	b = c
	if n < 0:
		return False
	return n % 3 == 0
num = int(input())
results = []
i = 0
while i < num:
	line = input()
	(a, b, c, n) = handle(line)
	result = solve(a, b, c, n)
	if result:
		results.append('YES')
	else:
		results.append('NO')
	i += 1
for line in results:
	print(line)


t = int(input())
for i in range(t):
	A = list(map(int, input().split()))
	n = A[-1]
	B = A[:3]
	B = sorted(B)
	a = B[0]
	b = B[1]
	c = B[2]
	x = c - a + c - b
	if n < x:
		print('NO')
	elif (n - x) % 3 == 0:
		print('YES')
	else:
		print('NO')


import sys
from bisect import bisect_left as bl, bisect_right as br, bisect
import math
from timeit import default_timer as dt
from itertools import zip_longest as zl
from itertools import groupby as gb
from itertools import combinations as comb
from itertools import combinations_with_replacement as cwr
from collections import defaultdict as dd
from collections import deque as dq
from collections import Counter as c
mod = pow(10, 9) + 7
mod2 = 998244353

def data():
	return input()

def l():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [[val for i in range(n)] for j in range(m)]
for _ in range(int(data())):
	(a, b, c, n) = sp()
	l = [a, b, c]
	l = sorted(l)
	d = l[2] - l[1] + l[2] - l[0]
	if (n - d) % 3 == 0 and n - d >= 0:
		print('YES')
	else:
		print('NO')


import sys
num_of_tests = int(input())
for i in range(num_of_tests):
	test_data_str = input()
	test_data = test_data_str.split()
	a = int(test_data[0])
	b = int(test_data[1])
	c = int(test_data[2])
	the_cnts = sorted(list([a, b, c]))
	coins = int(test_data[3])
	ab = abs(int(test_data[0]) - int(test_data[1]))
	bc = abs(int(test_data[1]) - int(test_data[2]))
	ac = abs(int(test_data[0]) - int(test_data[2]))
	the_diffs = sorted(list([ab, bc, ac]))
	diff1 = the_cnts[1] - the_cnts[0]
	if diff1 > coins:
		print('NO')
	else:
		coins = coins - diff1
		diff2 = 2 * (the_cnts[2] - the_cnts[1])
		if diff2 > coins:
			print('NO')
		else:
			leftover = coins - diff2
			if leftover % 3 == 0:
				print('YES')
			else:
				print('NO')


t = int(input())
for i in range(t):
	l = list(map(int, input().split()))
	m = l[0:3]
	m.sort()
	x = m[2] - m[0]
	y = m[2] - m[1]
	if x <= l[3]:
		if y <= l[3] - x:
			if (l[3] - x - y) % 3 == 0:
				print('YES')
			else:
				print('NO')
		else:
			print('NO')
	else:
		print('NO')


t = int(input())
for q in range(t):
	(a, b, c, n) = map(int, input().split())
	x = max(a, b, c)
	y = x - a + (x - b) + (x - c)
	if n < y or (n - y) % 3 != 0:
		print('NO')
	else:
		print('YES')


import sys

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

def mint():
	return int(minp())

def mints():
	return map(int, minp().split())

def solve():
	(a, b, c, n) = mints()
	m = max(max(a, b), c)
	n -= m - a + (m - b) + (m - c)
	if n < 0:
		print('NO')
	elif n % 3 != 0:
		print('NO')
	else:
		print('YES')
for i in range(mint()):
	solve()


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
sys.setrecursionlimit(10 ** 7)
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 main():
	t = I()
	rr = []
	for _ in range(t):
		a = LI()
		n = a[-1]
		a = a[:-1]
		m = max(a)
		t = sum((m - c for c in a))
		if t <= n and (n - t) % 3 == 0:
			rr.append('YES')
		else:
			rr.append('NO')
	return JA(rr, '\n')
print(main())


for _ in range(int(input())):
	(a, b, c, n) = map(int, input().split())
	coins = sorted([a, b, c])
	min_req = coins[-1] * 2 - coins[-2] - coins[-3]
	print(['NO', 'YES'][min_req <= n and (n - min_req) % 3 == 0])


a = int(input())
while a != 0:
	(b, c, d, n) = map(int, input().split())
	p = (n + b + d - 2 * c) / 3
	q = (n + c + d - 2 * b) / 3
	r = (n + b + c - 2 * d) / 3
	if p >= 0 and q >= 0 and (r >= 0):
		if p == int(p) and q == int(q) and (r == int(r)):
			print('YES')
		else:
			print('NO')
	else:
		print('NO')
	a -= 1


t = int(input())
while t > 0:
	t -= 1
	iline = input().rstrip().split()
	(a, b, c, n) = map(int, iline)
	share = (a + b + c + n) / 3
	if not share == int(share):
		print('NO')
	elif share - a < 0:
		print('NO')
	elif share - b < 0:
		print('NO')
	elif share - c < 0:
		print('NO')
	else:
		print('YES')


def ans(a, b, c, n):
	if (a + b + c + n) % 3 != 0:
		print('NO')
		return
	m = (a + b + c + n) // 3
	if m - a >= 0 and m - b >= 0 and (m - c >= 0):
		print('YES')
		return
	print('NO')
	return
for _ in range(int(input())):
	(a, b, c, n) = map(int, input().split())
	ans(a, b, c, n)


k = int(input())
out = ''
for i in range(k):
	s = input()
	(a, b, c, n) = tuple((int(x) for x in s.split()))
	m = max(a, b, c)
	d = abs(m - a) + abs(m - b) + abs(m - c)
	if (a + b + c + n) % 3 == 0 and n >= d:
		out += 'YES\n'
	else:
		out += 'NO\n'
print(out)


def coins(a, b, c, n):
	C = (a + n + b - 2 * c) / 3.0
	B = (a + n - b - C) / 2.0
	A = n - B - C
	if A >= 0 and B >= 0 and (C >= 0) and (C - int(C) == 0) and (B - int(B) == 0):
		print('YES')
	else:
		print('NO')
test = int(input())
for i in range(test):
	(a, b, c, n) = [int(i) for i in input().split(' ')]
	coins(a, b, c, n)


lines = int(input())
for i in range(lines):
	sav = [int(a) for a in input().split(' ')]
	avg = (sav[3] + sav[0] + sav[1] + sav[2]) / 3
	if avg >= max(sav[0], sav[1], sav[2]) and (not (sav[3] + sav[0] + sav[1] + sav[2]) % 3):
		print('YES')
	else:
		print('NO')


coins = []
for t in range(int(input())):
	coins = [int(i) for i in input().split()]
	threshold = int(coins[0] + coins[1] + coins[2] + coins[3]) / 3
	if (coins[0] + coins[1] + coins[2] + coins[3]) % 3 != 0 or coins[0] > threshold or coins[1] > threshold or (coins[2] > threshold):
		print('no')
	else:
		print('yes')


q = int(input())
for _ in range(q):
	(a, b, c, p) = [int(x) for x in input().split()]
	j = sorted([a, b, c])
	poverty = j[2] - j[1] + j[2] - j[0]
	if p < poverty:
		print('NO')
	elif (p - poverty) % 3 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
abcn = [list(map(int, input().split())) for i in range(t)]
for i in abcn:
	(a, b, c, n) = i
	tc = a + b + c + n
	need = 3 * max(a, b, c)
	if tc >= need and (tc - need) % 3 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(a, b, c, n) = map(int, input().split())
	max_amt = max(a, b, c)
	req_coin = 0
	for x in (a, b, c):
		req_coin += max_amt - x
	if n - req_coin < 0 or (n - req_coin) % 3 != 0:
		print('NO')
	else:
		print('YES')


t = int(input())
while t:
	t -= 1
	(a, b, c, n) = [int(x) for x in input().split()]
	bou = (a + b + c + n) % 3
	tou = (a + b + c + n) / 3
	if bou == 0 and a <= tou and (b <= tou) and (c <= tou):
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(a, b, c, n) = [int(i) for i in input().split(' ')]
	maxx = max(a, b, c)
	n -= maxx - a
	n -= maxx - b
	n -= maxx - c
	if n < 0 or n % 3 != 0:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	(a, b, c, n) = tuple(map(int, input().split()))
	total_coins = a + b + c + n
	if total_coins % 3 != 0:
		print('NO')
	else:
		each = total_coins // 3
		if each - a >= 0 and each - b >= 0 and (each - c >= 0):
			print('YES')
		else:
			print('NO')


def main():
	for _ in range(int(input())):
		(a, b, c, n) = map(int, input().split())
		big = max(a, b, c)
		if a != big:
			n -= big - a
		if b != big:
			n -= big - b
		if c != big:
			n -= big - c
		if n < 0 or n % 3 != 0:
			print('NO')
			continue
		print('YES')
main()


for cases in range(int(input())):
	a = list(map(int, input().split()))
	s = sum(a)
	if s % 3 == 0:
		val = s // 3
		if val >= max(a[0], a[1], a[2]):
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


t = int(input())
for i in range(t):
	coin = list(map(int, input().split()))
	s = sum(coin)
	if s % 3 == 0:
		N = coin[-1]
		abc = sorted(coin[:-1])
		coindiff1 = abc[2] - abc[0]
		coindiff2 = abc[2] - abc[1]
		if N >= coindiff2 + coindiff1:
			x = N - coindiff2 - coindiff1
			if x % 3 == 0:
				print('YES')
			else:
				print('NO')
		else:
			print('NO')
	else:
		print('NO')


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


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


T = int(input())
while T:
	(a, b, c, n) = map(int, input().split())
	s = a + b + c
	maxval = max(a, b, c)
	if 3 * maxval - s > n:
		print('NO')
	else:
		num = s % 3
		if (num + n) % 3 == 0:
			print('YES')
		else:
			print('NO')
	T -= 1


for t in range(int(input())):
	(a, b, c, n) = map(int, input().split())
	arr = [a, b, c]
	arr.sort()
	m = 2 * arr[2] - arr[1] - arr[0]
	if n < m:
		print('NO')
	else:
		s = n - m
		if s % 3 == 0:
			print('YES')
		else:
			print('NO')


def max(a, b, c):
	if a > b:
		if a > c:
			return a - b + a - c
		else:
			return c - a + c - b
	elif b > c:
		return b - a + b - c
	else:
		return c - a + c - b
t = int(input())
count = 0
while count < t:
	count += 1
	(x, y, z, k) = input().split()
	x = int(x)
	y = int(y)
	z = int(z)
	k = int(k)
	if (k - max(x, y, z)) % 3 == 0 and k - max(x, y, z) >= 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	ll = list(map(int, input().split()))
	x = ll[0]
	y = ll[1]
	z = ll[2]
	n = ll[3]
	maxx = max(x, y, z)
	s = maxx - x + (maxx - y) + (maxx - z)
	if s <= n:
		if (n - s) % 3 == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


from math import ceil, sqrt
n = int(input())
for i in range(n):
	(a, b, c, p) = [int(x) for x in input().split(' ')]
	to_balance = 3 * max(a, b, c) - a - b - c
	tmp = p - to_balance
	if tmp >= 0 and tmp % 3 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(a, b, c, n) = map(int, input().split())
	total = a + b + c + n
	perhead = total / 3
	aa = perhead - a
	bb = perhead - b
	cc = perhead - c
	m = max(a, b, c)
	if total % 3 == 0:
		s = 0
		for i in list([a, b, c]):
			s += m - i
		if s > n:
			print('NO')
		else:
			print('YES')
	else:
		print('NO')


m = int(input())
lst = []
for i in range(m):
	ls = list(map(int, input().split()))
	lst.append(ls)
for i in lst:
	mx = max(i[:3])
	s = sum(i[:3]) - 3 * mx
	if (i[-1] - abs(s)) % 3 == 0 and i[-1] - abs(s) >= 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(a, b, c, n) = list(map(int, input().strip().split()))
	d = (a + b + c + n) / 3
	if d == int(d) and a <= d and (b <= d) and (c <= d):
		print('YES')
	else:
		print('NO')


import math

def BuubleSort(a, b, c, n):
	l = [a, b, c]
	maxi = max(l)
	total = maxi - a + maxi - b + maxi - c
	if total == n:
		return 'YES'
	elif total > n:
		return 'NO'
	elif (n - total) % 3 == 0:
		return 'YES'
	else:
		return 'NO'

def main():
	t = int(input())
	for _ in range(t):
		(a, b, c, n) = map(int, input().split())
		ans = BuubleSort(a, b, c, n)
		print(ans)
main()


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


import sys
input = sys.stdin.readline

def inp():
	return int(input())

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

def insr():
	s = input()
	return list(s[:len(s) - 1])

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

def pr_list(a):
	print(*a, sep=' ')

def main():
	tests = inp()
	for test in range(tests):
		[a, b, c, n] = inlt()
		mean = a + b + c + n
		if mean % 3 != 0:
			print('NO')
		else:
			mean = mean / 3
			A = mean - a
			B = mean - b
			C = mean - c
			if A + B + C == n and A >= 0 and (B >= 0) and (C >= 0):
				print('YES')
			else:
				print('NO')
	return
main()


for _ in range(int(input())):
	(a, b, c, d) = map(int, input().split())
	s = sum([a, b, c, d])
	print('YES' if s // 3 == s / 3 and s // 3 >= max([a, b, c]) else 'NO')


t = int(input())
for i in range(t):
	(a, b, c, n) = map(int, input().split())
	x = (a + b + c + n) / 3
	if int(x) != x or x < max(a, b, c):
		print('NO')
	else:
		print('YES')


t = int(input())
ans = []
for i in range(0, t):
	(a, b, c, n) = map(int, input().split())
	sum = a + b + c + n
	mx = max(a, max(b, c))
	if sum % 3 == 0 and int(sum / 3) >= mx:
		ans.append('YES')
	else:
		ans.append('NO')
print(*ans, sep='\n')


q = int(input())
for _ in range(q):
	(a, b, c, n) = map(int, input().split())
	if (n + b + a + c) % 3 != 0:
		print('No')
	else:
		sum = int((n + a + b + c) / 3)
		print('No' if sum < a or sum < b or sum < c else 'Yes')


q = int(input())
for _ in range(q):
	(a, b, c, n) = map(int, input().split())
	t = (a + b + c + n) // 3
	if (a + b + c + n) % 3 == 0:
		d = 0
		d += t - a
		d += t - b
		d += t - c
		if t - a < 0 or t - b < 0 or t - c < 0:
			print('NO')
		elif d == n:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


n = int(input())
for i in range(n):
	a = [int(x) for x in input().split()]
	b = a[:3]
	if sum(a) % 3 != 0:
		print('NO')
	else:
		f = sum(a) // 3
		if f < max(b):
			print('NO')
		else:
			print('YES')


def input_type():
	num = int(input())
	for thing in range(num):
		q_1()

def q_1():
	inputs = input()
	list_1 = inputs.split(' ')
	list_2 = []
	for item in list_1:
		list_2 = list_2 + [int(item)]
	n = list_2.pop(3)
	list_3 = sorted(list_2)
	dif_1 = list_3[2] - list_3[1]
	dif_2 = list_3[2] - list_3[0]
	difs = dif_1 + dif_2
	last_dif = n - difs
	if last_dif % 3 == 0 and last_dif >= 0:
		print('YES')
	else:
		print('NO')
input_type()


for _ in range(int(input())):
	(a, b, c, n) = map(int, input().split())
	(a, b, c) = sorted([a, b, c])
	dif1 = c - a
	dif2 = c - b
	remian = n - dif1 - dif2
	if remian % 3 == 0 and remian >= 0:
		print('YES')
	else:
		print('NO')


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


from sys import stdin
r = stdin.readline

def main():
	cases = int(r())
	for case in range(cases):
		(a, b, c, n) = map(int, r().strip().split())
		arr = [a, b, c]
		arr.sort()
		ac = 0
		ac += arr[2] - arr[0]
		ac += arr[2] - arr[1]
		if ac <= n:
			if (n - ac) % 3 == 0:
				print('YES')
			else:
				print('NO')
		else:
			print('NO')
main()


for i in range(int(input())):
	(a, b, c, n) = map(int, input().split())
	maxz = max(a, b, c)
	da = maxz - a
	db = maxz - b
	dc = maxz - c
	d = da + db + dc
	if d > n:
		print('NO')
	else:
		n = n - d
		a = a + da
		if n % 3 == 0:
			print('YES')
		else:
			print('NO')


import sys

def solve(a, b, c, n):
	if (a + b + c + n) % 3 != 0:
		return False
	mx = max(a, b, c)
	return 3 * mx - (a + b + c) <= n
t = int(input())
for _ in range(t):
	ln = next(sys.stdin)
	(a, b, c, n) = map(int, ln.split())
	if solve(a, b, c, n):
		print('YES')
	else:
		print('NO')


from fractions import Fraction
t = int(input())
for _ in range(t):
	(a, b, c, n) = map(int, input().split())
	C = Fraction(-(2 * c - (b + a + n)) / 3)
	B = Fraction(-(b - a - n + C) / 2)
	A = Fraction(n - B - C)
	if a + A == b + B == c + C and A >= 0 and (B >= 0) and (C >= 0):
		print('YES')
	else:
		print('NO')


t = int(input())
i = 0
while i < t:
	k = list(map(int, input().split()))
	n = k.pop()
	k.sort()
	a = k[2] - k[1]
	b = k[2] - k[0]
	if (n - a - b) % 3 == 0 and n - a - b >= 0:
		print('YES')
	else:
		print('NO')
	i += 1


n = int(input())
while n:
	i = input().split()
	a = int(i[0])
	b = int(i[1])
	c = int(i[2])
	d = int(i[3])
	x = max(a, b, c)
	j = x - a
	k = x - b
	l = x - c
	t = j + k + l
	if t > d:
		print('NO')
	elif (d - t) % 3 == 0:
		print('YES')
	else:
		print('NO')
	n -= 1


t = int(input())
for _ in range(t):
	(a, b, c, n) = map(int, input().split())
	x = max(a, b, c)
	n1 = 3 * x - a - b - c
	if n < n1:
		print('No')
	else:
		z = n - n1
		if z == 0:
			print('Yes')
		elif z % 3 == 0:
			print('Yes')
		else:
			print('No')


import math
for _ in range(int(input())):
	(a, b, c, n) = map(int, input().split())
	s = 0
	if n > 0:
		res = (a + b + c + n) // 3
		count = 0
		for i in [a, b, c]:
			if i <= res:
				count += 1
		if count == 3:
			for i in [a, b, c]:
				s += res - i
			if s == n:
				print('YES')
			else:
				print('NO')
		else:
			print('NO')
	else:
		print('NO')


def f(l):
	s = l[:3]
	s.sort()
	n = s[2] * 2 - (s[0] + s[1])
	if l[-1] >= n:
		if (l[-1] - n) % 3 == 0:
			print('Yes')
		else:
			print('No')
	else:
		print('No')
v = int(input())
for i in range(v):
	g = str(input())
	x = map(int, g.split())
	f(list(x))


for _ in range(int(input())):
	(a, b, c, n) = [int(s) for s in input().split()]
	(a, b, c) = sorted([a, b, c])
	w = c - a + c - b
	if w > n:
		print('NO')
	elif (n - w) % 3 == 0:
		print('YES')
	else:
		print('NO')


import math

def main():
	(a, b, c, n) = map(int, input().split())
	if (a + b + c + n) % 3 == 0 and abs(a + b + c - 3 * max(a, b, c)) <= n:
		print('YES')
	else:
		print('NO')
t = int(input())
for i in range(t):
	main()


t = int(input())
for i in range(t):
	inn = input().split()
	a = int(inn[0])
	b = int(inn[1])
	c = int(inn[2])
	n = int(inn[3])
	if a == b and a == c and (n == 0):
		print('YES')
		continue
	mx = max([a, b, c])
	if mx == a:
		n -= a - b
		n -= a - c
	elif mx == b:
		n -= b - a
		n -= b - c
	elif mx == c:
		n -= c - b
		n -= c - a
	if n < 0:
		print('NO')
		continue
	print('YES' if n % 3 == 0 else 'NO')


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


n = int(input())
for _ in range(n):
	f = 0
	l = list(map(int, input().split()))
	if sum(l) % 3 == 0:
		t = sum(l) // 3
		if t == 0:
			for i in range(3):
				if l[i] != 0:
					f = 1
					break
		else:
			for i in range(3):
				if l[i] > t:
					f = 1
					break
	else:
		f = 1
	if f == 1:
		print('NO')
	else:
		print('YES')


qtd = int(input())
for x in range(qtd):
	line = input().split(' ')
	maxValue = int(line[0])
	poli = int(line.pop())
	for index in range(len(line)):
		sister = int(line[index])
		if index == 0:
			maxValue = sister
		if sister > maxValue or maxValue == sister:
			poli -= index * (sister - maxValue)
			maxValue = sister
		else:
			poli -= maxValue - sister
	if poli < 0 or poli % 3 != 0:
		print('NO')
	else:
		print('YES')


for _ in range(int(input().strip())):
	(a, b, c, n) = [int(__) for __ in input().strip().split()]
	arr = [a, b, c]
	arr.sort(reverse=True)
	(a, b, c) = arr
	diff = a - b + (a - c)
	if n < diff:
		print('NO')
	elif n == diff:
		print('YES')
	else:
		rem = n - diff
		print('YES' if rem % 3 == 0 else 'NO')


t = int(input())
for i in range(t):
	a = list(map(int, input().split()))
	sua = sum(a)
	su = sua // 3
	s1 = su - a[0]
	s2 = su - a[1]
	s3 = su - a[2]
	if s1 >= 0 and s2 >= 0 and (s3 >= 0) and (sua % 3 == 0):
		print('YES')
	else:
		print('NO')


for t in range(int(input())):
	(a, b, c, n) = map(int, input().split(' '))
	l = max(a, b, c)
	s = min(a, b, c)
	m = a + b + c - (l + s)
	check = True
	if 2 * l - (s + m) > n:
		check = False
	else:
		n -= 2 * l - (s + m)
		if n % 3 != 0:
			check = False
	if check:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	s = input().split(' ')
	(a, b, c, n) = (int(s[0]), int(s[1]), int(s[2]), int(s[3]))
	maxi = max(a, b, c)
	req = maxi - a + maxi - b + maxi - c
	diff = n - req
	if diff >= 0 and diff % 3 == 0:
		print('YES')
	else:
		print('NO')


k = int(input())
for i in range(0, k):
	(a, b, c, n) = map(int, input().split())
	d = max(a, b, c)
	sum = abs(d - a) + abs(d - b) + abs(d - c)
	f = n - sum
	if f % 3 == 0 and f >= 0:
		print('YES')
	else:
		print('NO')


test_case = int(input())
for i in range(test_case):
	values = list(map(int, input().split(' ')))
	k = max(values[:3]) * 3 - sum(values[:3])
	if values[3] - k < 0:
		print('NO')
	elif (values[3] - k) % 3 == 0:
		print('YES')
	else:
		print('NO')


from collections import *
import sys

def ri():
	return int(input())

def rl():
	return list(map(int, input().split()))
t = ri()
for _ in range(t):
	(a, b, c, n) = rl()
	l = [a, b, c]
	l.sort()
	(c, b, a) = l
	x = n - (b - c)
	y = x - 2 * (a - b)
	if y % 3 == 0 and x >= 0 and (y >= 0):
		print('YES')
	else:
		print('NO')


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


for Saquif_sohol in range(int(input())):
	(a, b, c, d) = map(int, input().split())
	x = max(a, b, c)
	z = min(a, b, c)
	y = a + b + c - x - z
	d -= x - y
	d -= x - z
	rslt = 0
	if d % 3 or d < 0:
		rslt = 1
	print(['YES', 'NO'][rslt])


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


t = int(input())
for i in range(t):
	ch = input()
	L = [int(i) for i in ch.split()]
	a = L[0]
	b = L[1]
	c = L[2]
	n = L[3]
	L2 = [a, b, c]
	L2.sort(reverse=True)
	n -= L2[0] - L2[1]
	n -= L2[0] - L2[2]
	if n % 3 == 0 and n >= 0:
		print('YES')
	else:
		print('NO')


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


I = input
pr = print
for _ in range(int(I())):
	(a, b, c, n) = map(int, I().split())
	pr('YNEOS'[bool((a + b + c + n) % 3) or not ((a + b + c + n) // 3 >= a and (a + b + c + n) // 3 >= b and ((a + b + c + n) // 3 >= c))::2])


t = int(input())
for i in range(t):
	inps = input()
	inps = list(map(int, inps.split()))
	a = inps[0]
	b = inps[1]
	c = inps[2]
	n = inps[3]
	max_ = max(a, b, c)
	if max_ == a:
		x = a - b
		y = a - c
		if n >= x + y:
			remaining = n - (x + y)
			if remaining % 3 == 0:
				print('YES')
			else:
				print('NO')
		else:
			print('NO')
	elif max_ == b:
		x = b - a
		y = b - c
		if n >= x + y:
			remaining = n - (x + y)
			if remaining % 3 == 0:
				print('YES')
			else:
				print('NO')
		else:
			print('NO')
	else:
		x = c - a
		y = c - b
		if n >= x + y:
			remaining = n - (x + y)
			if remaining % 3 == 0:
				print('YES')
			else:
				print('NO')
		else:
			print('NO')


import atexit
import io
import sys
_INPUT_LINES = sys.stdin.read().splitlines()
input = iter(_INPUT_LINES).__next__
_OUTPUT_BUFFER = io.StringIO()
sys.stdout = _OUTPUT_BUFFER

@atexit.register
def write():
	sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
for _ in range(int(input())):
	(a, b, c, n) = [int(x) for x in input().split()]
	coins = [a, b, c]
	coins.sort()
	(a, b, c) = coins
	dist = c - b + (c - a)
	if dist <= n and (n - dist) % 3 == 0:
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	vals = list(map(int, input().split()))
	som = sum(vals)
	if som % 3 != 0:
		print('NO')
		continue
	ok = True
	for j in range(3):
		if vals[j] > som // 3:
			ok = False
			break
	if ok:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	x = list(map(int, input().split()))
	m = max(x[:len(x) - 1])
	for i in range(len(x) - 1):
		x[i] = m - x[i]
	s = sum(x[:3])
	if x[-1] - s >= 0 and (x[-1] - s) % 3 == 0:
		print('YES')
	else:
		print('NO')


import sys
input = sys.stdin.readline
output = sys.stdout.write

def main():
	tests = int(input().rstrip())
	for i in range(tests):
		list_ = list(map(int, input().rstrip().split()))
		coins = list_.pop(-1)
		list_.sort()
		dif = list_[2] - list_[1] + (list_[2] - list_[0])
		state = False
		if coins >= dif:
			dif_2 = dif - coins
			if dif_2 % 3 == 0:
				state = True
		if state:
			output('YES')
		else:
			output('NO')
		output('\n')
main()


t = int(input())
for _ in range(t):
	a = list(map(int, input().split()))
	b = a[0]
	c = a[1]
	d = a[2]
	e = a[3]
	sum = b + c + d + e
	if sum % 3 != 0 or sum / 3 < b or sum / 3 < c or (sum / 3 < d):
		print('NO')
	else:
		print('YES')


n = int(input())
ans = []
for i in range(n):
	(a, b, c, n) = map(int, input().split())
	if a + b + c + n - 3 * a < 0 or a + b + c + n - 3 * b < 0 or a + b + c + n - 3 * c < 0 or (a + b + c + n - 3 * a) % 3 or (a + b + c + n - 3 * b) % 3 or (a + b + c + n - 3 * c) % 3:
		ans.append('NO')
	else:
		ans.append('YES')
for j in ans:
	print(j)


t = int(input())
for x in range(t):
	(a, b, c, n) = map(int, input().split())
	if a >= b and a >= c:
		ans = n - (a - b + (a - c))
		if ans % 3 == 0 and ans >= 0:
			print('YES')
		else:
			print('NO')
	elif b >= a and b >= c:
		ans = n - (b - a + (b - c))
		if ans % 3 == 0 and ans >= 0:
			print('YES')
		else:
			print('NO')
	else:
		ans = n - (c - a + (c - b))
		if ans % 3 == 0 and ans >= 0:
			print('YES')
		else:
			print('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')

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

def array():
	return [int(i) for i in input().split()]
for _ in range(int(input())):
	(a, b, c, tot) = value()
	(a, b, c) = sorted((a, b, c))
	tot -= c - a + (c - b)
	if tot % 3 == 0 and tot >= 0:
		print('YES')
	else:
		print('NO')


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


tc = int(input())
for _ in range(tc):
	(a, b, c, k) = list(map(int, input().split()))
	now = True if (a + b + c + k) % 3 == 0 else False
	if now == True and (a + b + c + k) // 3 >= max(a, b, c):
		print('YES')
	else:
		print('NO')


t = int(input())
while t > 0:
	arr = list(map(int, input().split()))
	n = arr[-1]
	arr.pop()
	arr.sort()
	if (n - 2 * arr[-1] + arr[0] + arr[1]) % 3 == 0 and n + arr[0] >= arr[-1] and (n - 2 * arr[-1] + arr[0] + arr[1] >= 0):
		print('YES')
	else:
		print('NO')
	t -= 1


import math
import os
import random
import re
import sys
save = []

def coins(p, q, r, s):
	arr = []
	arr.append(p)
	arr.append(q)
	arr.append(r)
	arr.sort()
	d = arr[2] - arr[0] + (arr[2] - arr[1])
	diff = s - d
	if d == s:
		return 'YES'
	elif d < s and diff % 3 == 0:
		return 'YES'
	else:
		return 'NO'
for i in range(int(input())):
	pqrs = input().split()
	p = int(pqrs[0])
	q = int(pqrs[1])
	r = int(pqrs[2])
	s = int(pqrs[3])
	result = coins(p, q, r, s)
	save.append(result)
for i in save:
	print(i, end='\n')


arr = []
test_cases = int(input(''))
for x in range(test_cases):
	a = []
	a = list(map(int, input().split()))
	arr.append(a)
for o in range(test_cases):
	summ = arr[o][0] + arr[o][1] + arr[o][2] + arr[o][3]
	if summ % 3 == 0 and summ / 3 >= max(arr[o][0], arr[o][1], arr[o][2]):
		print('Yes')
	else:
		print('No')


for i in range(int(input())):
	X = list(map(int, input().split()))
	print('YES' if sum(X) % 3 == 0 and all([True if i <= sum(X) / 3 else False for i in X[:3]]) else 'NO')


t = int(input())
i = 0
output = []
while i < t:
	(a, b, c, n) = map(int, input().split())
	sis = [a, b, c]
	maxi = max(sis)
	for x in sis:
		n -= maxi - x
	if n % 3 == 0 and n >= 0:
		output.append('YES')
	else:
		output.append('NO')
	i += 1
for y in output:
	print(y)


for _ in range(int(input())):
	l = list(map(int, input().split()))
	if sum(l) % 3:
		print('NO')
	else:
		x = sum(l) // 3
		(a, b, c) = (max(0, x - l[0]), max(0, x - l[1]), max(0, x - l[2]))
		if a + b + c == l[3]:
			print('YES')
		else:
			print('NO')


n = int(input())
for i in range(0, n):
	(a, b, c, n) = input().split()
	a = int(a)
	b = int(b)
	c = int(c)
	n = int(n)
	max = None
	if a > b and a > c:
		max = a
	elif b > c:
		max = b
	else:
		max = c
	nd = 0
	nd = nd + max - a
	nd = nd + max - b
	nd = nd + max - c
	n = n - nd
	if n < 0:
		print('NO')
	elif n % 3 == 0:
		print('YES')
	else:
		print('NO')


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


import sys
import math
import itertools
import functools
import collections
import operator

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)

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)
t = ii()
for _ in range(t):
	(a, b, c, n) = mi()
	if sum([a, b, c, n]) // 3 < max([a, b, c]) or sum([a, b, c, n]) % 3:
		print('NO')
	else:
		print('YES')


t = int(input())
for number in range(t):
	numbers = [int(x) for x in input().split()]
	n = int(numbers[3])
	l = numbers[:3]
	l.sort()
	n -= 2 * int(l[2]) - int(l[1]) - int(l[0])
	if n % 3 == 0 and n >= 0:
		print('YES')
	else:
		print('NO')


tests = int(input())
for i in range(tests):
	lis = list(map(int, input().split()))
	if sum(lis) % 3 == 0:
		target = sum(lis) / 3
		if (lis[0] <= target and lis[1] <= target) and lis[2] <= target:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


p = int(input())
for i in range(p):
	l = input().split()
	(a, b, c, n) = (int(l[0]), int(l[1]), int(l[2]), int(l[3]))
	l = [a, b, c]
	_max = max(a, b, c)
	_m_index = l.index(_max)
	for i in range(len(l)):
		n -= _max - l[i]
	if n >= 0:
		if n % 3 == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


import math
a = int(input())
for i in range(0, a):
	(a, b, c, n) = map(int, input().split())
	summ = a + b + c + n
	if (a + b + c + n) % 3 == 0 and a <= summ // 3 and (b <= summ // 3) and (c <= summ // 3):
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(a, b, c, n) = map(int, input().split())
	flag = 0
	maxx = max(a, b, c)
	n -= maxx - a
	a += maxx - a
	if n < 0:
		flag = 1
		print('NO')
		continue
	n -= maxx - b
	b += maxx - b
	if n < 0:
		flag = 1
		print('NO')
		continue
	n -= maxx - c
	c += maxx - c
	if n < 0:
		flag = 1
		print('NO')
		continue
	if n % 3 == 0:
		print('YES')
	else:
		print('NO')


def func(n):
	for i in range(n):
		l = list(map(int, input().split()))
		counter = l[-1]
		a = l[0]
		b = l[1]
		c = l[2]
		x = max(a, b, c)
		flag = True
		counter -= x - a
		counter -= x - b
		counter -= x - c
		if counter % 3 != 0 or counter < 0:
			print('NO')
		else:
			print('YES')
n = int(input())
func(n)


t = int(input())
while t != 0:
	(a, b, c, n) = map(int, input().split())
	x = max(a, b, c)
	if a != x or b != x or c != x:
		n1 = x - a
		n2 = x - b
		n3 = x - c
		if n >= n1 + n2 + n3:
			a += n1
			b += n2
			c += n3
			n = n - (n1 + n2 + n3)
			if n % 3 == 0:
				print('YES')
			else:
				print('NO')
		else:
			print('NO')
	elif n % 3 == 0:
		print('YES')
	else:
		print('NO')
	t -= 1


n = int(input())
for i in range(0, n):
	a = list(map(int, input().split()))
	l = sum(a)
	if l % 3 == 0:
		q = l // 3
		d = q - a[0]
		e = q - a[1]
		f = q - a[2]
		if d < 0:
			d = d * -1
		if e < 0:
			e = e * -1
		if f < 0:
			f = f * -1
		if a[3] == d + e + f:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


t = int(input())
while t > 0:
	st = input().split()
	l = []
	for i in range(len(st) - 1):
		l.append(int(st[i]))
	n = int(st[3])
	ma1 = max(l) * 3
	su1 = sum(l)
	dif = ma1 - su1
	if n >= dif:
		n -= dif
		if n % 3 == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')
	t -= 1


t = int(input())
for zz in range(t):
	(a, b, c, n) = map(int, input().split())
	ta = [a, b, c]
	ta.sort()
	ta = list(reversed(ta))
	res = 0
	res += ta[0] - ta[2]
	res += ta[0] - ta[1]
	if res > n or (n - res) % 3 > 0:
		print('NO')
	else:
		print('YES')


T = int(input())
for z in range(T):
	(a, b, c, n) = map(int, input().split())
	if (a + b + c + n) % 3 == 0:
		avg = (a + b + c + n) // 3
		if a <= avg and b <= avg and (c <= avg):
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


def collecting_coins(a, b, c, n):
	max_number = max((a, b, c))
	delta_a = max_number - a
	delta_b = max_number - b
	delta_c = max_number - c
	n = n - (delta_a + delta_b + delta_c)
	if n == 0 or (n > 0 and n % 3 == 0):
		return True
	else:
		return False

def intify_arr(str_line):
	int_arr = []
	str_arr = str_line.split(' ')
	for number in str_arr:
		int_arr.append(int(number))
	return int_arr

def main():
	t = int(input())
	for _ in range(t):
		str_line = input()
		int_arr = intify_arr(str_line)
		if collecting_coins(int_arr[0], int_arr[1], int_arr[2], int_arr[3]):
			print('YES')
		else:
			print('NO')
main()


for _ in range(int(input())):
	(a, b, c, n) = map(int, input().split())
	max_val = max(a, b, c)
	if max_val == a:
		d1 = max_val - b
		d2 = max_val - c
	elif max_val == b:
		d1 = max_val - a
		d2 = max_val - c
	else:
		d1 = max_val - b
		d2 = max_val - a
	if (n - (d1 + d2)) % 3 == 0 and n - (d1 + d2) >= 0:
		print('YES')
	else:
		print('NO')


t = int(input())
while t:
	t = t - 1
	(a, b, c, n) = map(int, input().split())
	x = []
	x.append(a)
	x.append(b)
	x.append(c)
	x.sort()
	f = x[2] - x[1]
	k = x[2] - x[0]
	n = n - (f + k)
	if n % 3 == 0 and n >= 0:
		print('YES')
	else:
		print('NO')


t = int(input(''))
for i in range(t):
	inp = input('')
	inp_lst = [int(i) for i in inp.split()]
	n = inp_lst[3]
	inp_lst = inp_lst[0:3]
	inp_lst.sort()
	A = inp_lst[2]
	B = inp_lst[1]
	C = inp_lst[0]
	to_eqaul = A - B + (A - C)
	if A - B + (A - C) <= n and (n - to_eqaul) % 3 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
while t:
	q = list(map(int, input().split()))
	s = sum(q)
	if s % 3 == 0:
		c = 0
		p = s / 3
		if q[0] > p or q[1] > p or q[2] > p:
			c = 1
		if c == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')
	t -= 1


for _ in range(int(input())):
	(a, b, c, t) = map(int, input().split())
	sm = a + b + c + t
	if sm % 3 == 0:
		if sm // 3 >= max(a, b, c):
			print('YES')
		else:
			print('NO')
	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, c, n) = map(int, sys.stdin.readline().split(' '))
	give = (a + b + c + n) // 3
	x = give - a
	y = give - b
	z = give - c
	if give * 3 == a + b + c + n and x >= 0 and (y >= 0) and (z >= 0) and (x + y + z == n):
		print('YES')
	else:
		print('NO')
if fileoperation:
	sys.stdout = orig_stdout
	sys.stdin = orig_stdin
	inputfile.close()
	outputfile.close()


t = int(input())
for i in range(t):
	coins = list(map(int, input().split()))[:4]
	max_coin = max(coins[:3])
	total = sum(coins)
	possibility = total % 3
	check = total // 3
	if possibility == 0 and total // 3 >= max_coin:
		print('YES')
	else:
		print('NO')


def main():
	for _ in range(int(input())):
		a = list(map(int, input().split()))
		s = list(reversed(sorted(a[:3])))
		n = a[3]
		need = 0
		need += s[0] - s[1]
		need += s[0] - s[2]
		if need > n:
			print('NO')
		elif (n - need) % 3 == 0:
			print('YES')
		else:
			print('NO')
main()


for _ in range(int(input())):
	(a, b, c, d) = map(int, input().split())
	if d == 0:
		if a == b and b == c and (c == a):
			print('YES')
		else:
			print('NO')
	else:
		s1 = max(a, max(b, c))
		a1 = s1 - a
		b1 = s1 - b
		c1 = s1 - c
		tsum = a1 + b1 + c1
		if tsum <= d and (d - tsum) % 3 == 0:
			print('YES')
		else:
			print('NO')


N = int(input())
for _ in range(N):
	(a, b, c, n) = [int(x) for x in input().split()]
	mx = max([a, b, c])
	mn_count = sum([mx - x for x in [a, b, c]])
	n -= mn_count
	if n >= 0 and n % 3 == 0:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(A, B, C, N) = map(int, input().split())
	k = A + B + C + N
	m = k // 3
	if k % 3 == 0 and m >= A and (m >= B) and (m >= C):
		print('YES')
	else:
		print('NO')


from collections import Counter
from collections import defaultdict
import math
t = int(input())
for _ in range(0, t):
	(a, b, c, n) = list(map(int, input().split()))
	l = [a, b, c]
	l.sort()
	diff = n - (l[2] - l[1]) - (l[2] - l[0])
	if diff < 0 or diff % 3 != 0:
		print('NO')
	else:
		print('YES')


t = int(input())
while t > 0:
	(a, b, c, n) = [int(ele) for ele in input().split()]
	x = max(a, b, c)
	res = 0
	if a != x:
		res += x - a
	if b != x:
		res += x - b
	if c != x:
		res += x - c
	n -= res
	if n < 0:
		print('NO')
	elif n % 3 == 0:
		print('YES')
	else:
		print('NO')
	t -= 1


def coins(a):
	if sum(a) % 3 == 0:
		s = sum(a)
		A = abs(s // 3 - a[0])
		B = abs(s // 3 - a[1])
		C = abs(s // 3 - a[2])
		if a[0] + A == a[1] + B and a[1] + B == a[2] + C and (a[2] + C == a[0] + A):
			return 'YES'
		else:
			return 'NO'
	else:
		return 'NO'
n = int(input())
I = []
for i in range(n):
	k = list(map(int, input().split()))
	I.append(k)
for i in range(n):
	print(coins(I[i]))


n = int(input())
nabors = []
for i in range(n):
	m = input().split(' ')
	(a, b, c, x) = m
	nabors.append([int(a), int(b), int(c), int(x)])
for i in nabors:
	mon = i[:3]
	n = i[3]
	mon.sort(reverse=True)
	(a, b, c) = mon
	x = n - (a - c) - (a - b)
	if x % 3 == 0 and x >= 0:
		print('YES')
	else:
		print('NO')


t = int(input())
results = []
for i in range(t):
	(a, b, c, n) = map(int, input().split())
	total = a + b + c + n
	aver = total / 3
	if a > aver or b > aver or c > aver or (total % 3 != 0):
		result = 'NO'
	else:
		result = 'YES'
	results.append(result)
for result in results:
	print(result)


t = int(input())
for i in range(t):
	o = list(map(int, input().split()))
	a = o[0]
	b = o[1]
	c = o[2]
	n = o[3]
	if n == 0:
		if a == b and b == c:
			print('YES')
		else:
			print('NO')
	else:
		k = max(a, b, c)
		x = k - a
		y = k - b
		z = k - c
		n = n - (x + y + z)
		if n >= 0:
			if n % 3 == 0:
				print('YES')
			else:
				print('NO')
		else:
			print('NO')


from functools import reduce

def factors(n):
	k = sorted(list(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5 + 1)) if n % i == 0)))))
	return k[1:]

def solve():
	(a, b, c, n) = map(int, input().split())
	sss = 'YES'
	(aa, bb, cc) = sorted([a, b, c])
	n -= cc - aa
	if n < 0:
		sss = 'NO'
	n -= cc - bb
	if n < 0:
		sss = 'NO'
	if n % 3 != 0:
		sss = 'NO'
	print(sss)
t = int(input())
for _ in range(0, t):
	solve()


t = int(input())
for i in range(t):
	numi = list(map(int, input().split()))
	sumi = sum(numi)
	if sumi % 3 == 0 and max(numi[0:3]) <= sumi / 3:
		print('YES')
	else:
		print('NO')


import sys
t = int(sys.stdin.readline())
for _ in range(t):
	(a, b, c, n) = map(int, sys.stdin.readline().split())
	l = [a, b, c]
	l.sort()
	(x, y) = (l[2] - l[1], l[2] - l[0])
	z = n - (x + y)
	if z < 0:
		print('NO')
	elif z % 3 == 0:
		print('YES')
	else:
		print('NO')


def main():
	for _ in range(int(input())):
		(a, b, c, d) = [int(i) for i in input().split()]
		l = [a, b, c]
		l.sort()
		diff = l[2] - l[1]
		diff += l[2] - l[0]
		if diff > d:
			print('NO')
		elif (sum(l) + d) % 3 != 0:
			print('NO')
		else:
			print('YES')
main()


def run():
	(a, b, c, n) = [int(i) for i in input().split()]
	nn = max([a, b, c])
	ret = sum([nn - a, nn - b, nn - c])
	if n < ret:
		print('NO')
		return
	else:
		if (n - ret) % 3 != 0:
			print('NO')
		else:
			print('YES')
		return
n = int(input())
for i in range(n):
	run()


t = int(input())
for i in range(t):
	(a, b, c, n) = [int(i) for i in input().split()]
	maxim = max(a, b, c)
	sum = 3 * maxim - a - b - c
	n -= sum
	if n >= 0 and n % 3 == 0:
		print('YES')
	else:
		print('NO')


for _ in [0] * int(input()):
	a = (*map(int, input().split()),)
	s = sum(a)
	print('YNEOS'[s % -3 | s - 3 * max(a[:3]) < 0::2])


for _ in [0] * int(input()):
	(a, b, c, n) = map(int, input().split())
	max_ = max(a, b, c)
	if 3 * max_ - a - b - c > n:
		print('NO')
	elif (n + a + b + c) % 3 is not 0:
		print('NO')
	else:
		print('YES')
	del a
	del b
	del c
	del n
	del max_


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


t = int(input(''))
for i in range(t):
	(a, b, c, n) = map(int, input('').split())
	l = [a, b, c]
	m = max(l)
	d1 = m - min(l)
	l.remove(min(l))
	d2 = m - min(l)
	n = n - (d1 + d2)
	ans = n / 3
	if ans != int(ans):
		print('NO')
	elif ans < 0:
		print('NO')
	else:
		print('YES')


for _ in [0] * int(input()):
	(a, b, c, n) = map(int, input().split(' '))
	mx = max(a, max(b, c))
	remain = n - (mx - a + (mx - b) + (mx - c))
	if remain >= 0 and remain % 3 == 0:
		print('YES')
	else:
		print('NO')


for t in range(int(input())):
	coins = [int(i) for i in input().split()]
	k = sum(coins)
	if k % 3 == 0 and k / 3 >= max(coins[:3]):
		print('YES')
	else:
		print('NO')


t = int(input())
for test in range(t):
	(a, b, c, n) = map(int, input().split())
	total = a + b + c + n
	if total % 3 != 0:
		print('NO')
	else:
		max_num = max(a, b, c)
		cha1 = max_num - a
		cha2 = max_num - b
		cha3 = max_num - c
		if n < cha1 + cha2 + cha3:
			print('NO')
		elif (n - (cha1 + cha2 + cha3)) % 3 == 0:
			print('YES')
		else:
			print('NO')


for i in range(int(input())):
	(f1, f2, f3, n) = map(int, input().split())
	f = [f1, f2, f3]
	f.sort()
	c = f[-1]
	a = f[0]
	b = f[1]
	h = c - b + (c - a)
	if h > n:
		print('NO')
		continue
	if (n - h) % 3 == 0:
		print('YES')
		continue
	print('NO')


def valid(amounts):
	val = 0
	for i in amounts:
		val += i
	if val % 3 == 0:
		maxV = 0
		for i in range(len(amounts) - 1):
			if amounts[i] > amounts[maxV]:
				maxV = i
		total = 0
		for i in range(len(amounts)):
			if i != maxV:
				total += amounts[i]
		if total // (len(amounts) - 2) < amounts[maxV]:
			return 'NO'
		return 'YES'
	return 'NO'
input()
while True:
	try:
		vals = input()
		amounts = []
		vals = vals.split(' ')
		for i in vals:
			amounts.append(int(i))
		print(valid(amounts))
	except EOFError:
		break


def call():
	(a, b, c, n) = map(int, input().split())
	l = [a, b, c]
	l.sort()
	n -= 2 * l[2] - l[1] - l[0]
	print(('YES', 'NO')[n < 0 or n % 3 != 0])
for _ in range(int(input())):
	call()


results = []
for i in range(0, int(input())):
	vals = input().split()
	vals = [int(i) for i in vals]
	n = vals[3]
	vals = vals[:-1]
	vals.sort()
	vals[2] = vals[2] * 2
	finalval = n - (vals[2] - vals[1] - vals[0])
	if finalval % 3 != 0 or finalval < 0:
		results.append('NO')
	else:
		results.append('YES')
for i in results:
	print(i)


t = int(input())
for i in range(t):
	(a, b, c, n) = [int(z) for z in input().split(' ')]
	C = max(a, b, c)
	A = min(a, b, c)
	B = a + b + c - A - C
	if (n - (C - A) - (C - B)) % 3 == 0 and n - (C - A) - (C - B) >= 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(a, b, c, n) = [int(tmp) for tmp in input().split()]
	k = max(a, b, c)
	x = abs(k - a) + abs(k - b) + abs(k - c)
	if x > n:
		print('NO')
	elif (n - x) % 3 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
while t:
	t -= 1
	(*a, n) = list(map(int, input().split()))
	val = n - (3 * max(a) - sum(a))
	if val >= 0 and val % 3 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for q in range(t):
	a = input().split(' ')
	b = []
	for j in a:
		b.append(int(j))
	res = max(b[0], b[1], b[2])
	res = res - b[0] + res - b[1] + res - b[2]
	if b[3] >= res:
		if (b[3] - res) % 3 == 0:
			print('YES')
		else:
			print('NO')
		q += 1
	else:
		print('NO')
		q += 11


def largest(a, b, c):
	if a >= b and a >= c:
		return a
	elif b >= a and b >= c:
		return b
	else:
		return c
t = int(input())
list = []
for i in range(t):
	(a, b, c, n) = [int(x) for x in input().split()]
	l = largest(a, b, c)
	d = 3 * l - a - b - c
	if n >= d and (n - d) % 3 == 0:
		list.append('YES')
	else:
		list.append('NO')
for x in list:
	print(x)


for _ in range(int(input())):
	(*p, n) = map(int, input().split())
	summ = sum(p)
	maxx = max(p)
	print('YES' if (summ + n) / 3 >= maxx and (summ + n) % 3 == 0 else 'NO')


t = int(input())
for t in range(t):
	(a, b, c, q) = map(int, input().split())
	p = max(a, b, c)
	q -= 3 * p - a - b - c
	if q < 0:
		print('NO')
	elif q % 3 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
while t:
	t -= 1
	(a, b, c, n) = map(int, input().split())
	k = max(a, b, c)
	if k == 0:
		if n % 3 == 0:
			print('YES')
			continue
		else:
			print('NO')
			continue
	(x, y, z) = (abs(k - a), abs(k - b), abs(k - c))
	if n < x + y + z:
		print('NO')
	elif (n - x - y - z) % 3 == 0:
		print('YES')
	else:
		print('NO')


def f(a, b, c, n):
	y = n + a + b + c
	if y % 3 == 0:
		y //= 3
		if y - a >= 0 and y - b >= 0 and (y - c >= 0):
			return 'YES'
	return 'NO'
for _ in range(int(input())):
	(a, b, c, n) = map(int, input().split())
	print(f(a, b, c, n))


try:
	for _ in range(int(input())):
		(a, b, c, d) = map(int, input().split())
		l = [a, b, c]
		l.sort()
		if l[2] - l[0] + (l[2] - l[1]) <= d:
			s = d - (l[2] - l[0] + (l[2] - l[1]))
			if s == 0 or (s >= 3 and s % 3 == 0):
				print('YES')
			else:
				print('NO')
		else:
			print('NO')
except:
	pass


def collectingCoins(arr):
	(A, B, C, P) = (arr[0], arr[1], arr[2], arr[3])
	M = max(max(A, B), C)
	if M * 3 - (A + B + C) <= P:
		P -= M * 3 - (A + B + C)
		if P == 0 or P % 3 == 0:
			return 'YES'
	return 'NO'
tc = int(input())
for i in range(tc):
	inp = list(map(int, input().split()))
	print(collectingCoins(inp))


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, c, n) = Read.list_int()
	m = max(a, b, c)
	s = a + b + c + n
	if s % 3 == 0 and s / 3 >= m:
		print('YES')
	else:
		print('NO')
query_count = Read.int()
while query_count:
	query_count -= 1
	solve()


t = int(input())
for _ in range(0, t):
	(a, b, c, n) = map(int, input().split())
	ans = 'YES'
	(aa, bb, cc) = sorted([a, b, c])
	n -= cc - aa
	if n < 0:
		ans = 'NO'
	n -= cc - bb
	if n < 0:
		ans = 'NO'
	if n % 3 != 0:
		ans = 'NO'
	print(ans)


for _ in range(int(input())):
	ls = list(map(int, input().split()))
	s = sum(ls)
	if s % 3 == 0:
		k = s // 3
		if k < ls[0] or k < ls[1] or k < ls[2]:
			print('NO')
		else:
			print('YES')
	else:
		print('NO')


z = int(input())
for i in range(z):
	a = input().split()
	l = []
	for j in a:
		l.append(int(j))
	l1 = l[0:3]
	n = l[3]
	l1 = sorted(l1)
	if l1[2] - l1[1] + l1[2] - l1[0] > n:
		print('NO')
	elif (n - (l1[2] - l1[1] + l1[2] - l1[0])) % 3 == 0:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(a, b, c, n) = map(int, input().split())
	res = sum([max(a, b, c) - i for i in [a, b, c]])
	print('YES' if (n - res) % 3 == 0 and n >= res else 'NO')


import sys, math
wtf = sys.stdin.read()
wtf = wtf.strip().split('\n')
T = int(wtf[0])
assert T >= 1 and T <= int(10000.0), 'Precondition failure'
for t in wtf[1:]:
	c = list(map(int, t.split()))
	(q, r) = divmod(sum(c), 3)
	q = max(q, c[0])
	q = max(q, c[1])
	q = max(q, c[2])
	if r == 0:
		R = c[3]
		R -= q - c[0]
		R -= q - c[1]
		R -= q - c[2]
		if R >= 0:
			print('YES')
			continue
	print('NO')


for _ in range(int(input())):
	(*a, n) = map(int, input().split())
	aux = n - sum((max(a) - i for i in a))
	print(['YES', 'NO'][aux % 3 != 0 or aux < 0])


from sys import stdin
t = int(stdin.readline())
while t:
	t -= 1
	(a, b, c, n) = map(int, stdin.readline().split())
	m = max(a, b, c)
	d = 3 * m - a - b - c
	if d > n:
		print('NO')
	else:
		n -= d
		if n % 3 == 0:
			print('YES')
		else:
			print('NO')


cases = int(input())
while cases:
	(a, b, c, n) = map(int, input().split())
	cases -= 1
	n_rem = n - (max(a, b, c) * 3 - (a + b + c))
	if n_rem < 0:
		print('NO')
	elif n_rem % 3 != 0:
		print('NO')
	else:
		print('YES')


def collect_coins():
	(a, b, c, n) = [int(x) for x in input().split()]
	mx = max([a, b, c])
	n -= mx - a + (mx - b) + (mx - c)
	if n > -1 and n % 3 == 0:
		print('YES')
	else:
		print('NO')
n = int(input())
for _ in range(n):
	collect_coins()


t = int(input())
for i in range(t):
	n = input()
	n = n.split()
	nn = list()
	for j in n:
		nn.append(int(j))
	ma = max(nn[0], nn[1], nn[2])
	su = ma - nn[0] + (ma - nn[1]) + (ma - nn[2])
	k = nn[3] - su
	if su > nn[3]:
		print('NO')
	elif su == nn[3]:
		print('YES')
	elif k % 3 == 0:
		print('YES')
	elif k == 0:
		print('YES')
	else:
		print('NO')


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


t = int(input())
while t:
	t = t - 1
	a = list(map(int, input().split()))
	b = max(a[0], a[1], a[2])
	c = 3 * b - a[0] - a[1] - a[2]
	if c > a[3]:
		print('NO')
	elif c == a[3]:
		print('YES')
	elif (a[3] - c) % 3:
		print('NO')
	else:
		print('YES')


import sys
t = int(sys.stdin.readline())
for i in range(t):
	(a, b, c, n) = (int(v) for v in sys.stdin.readline().split())
	(a, b, c) = sorted([a, b, c])
	nm = n - (c - a) - (c - b)
	print('YES' if nm >= 0 and nm % 3 == 0 else 'NO')


t = int(input())
for ti in range(t):
	d = input().split()
	a = int(d[0])
	b = int(d[1])
	c = int(d[2])
	n = int(d[3])
	if a <= b and c <= b:
		x = 2 * b - a - c
	elif b <= a and c <= a:
		x = 2 * a - c - b
	elif b <= c and a <= c:
		x = 2 * c - a - b
	if n >= x:
		if (n - x) % 3 == 0:
			print('Yes')
		else:
			print('No')
	else:
		print('No')


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


def get_coeffs(a, b, c, n):
	res = []
	res.append((b + c + n - 2 * a) / 3)
	res.append(res[0] + a - b)
	res.append(res[0] + a - c)
	return res
num_samples = input()
for i in range(0, int(num_samples)):
	sample = input()
	sample_arr = sample.split(' ')
	a = int(sample_arr[0])
	b = int(sample_arr[1])
	c = int(sample_arr[2])
	n = int(sample_arr[3])
	res = get_coeffs(a, b, c, n)
	no = False
	for coeff in res:
		if coeff < 0 or round(coeff) != coeff:
			no = True
	if no:
		print('NO')
	else:
		print('YES')


t = int(input())
for _ in range(t):
	(a, b, c, n) = map(int, input().split())
	(a, b, c) = sorted([a, b, c])
	x = 2 * c - b - a
	if n < x:
		print('NO')
	elif (x - n) % 3 == 0:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	l = input().split()
	for i in range(0, len(l)):
		l[i] = int(l[i])
	x = l[3]
	del l[3]
	l.sort()
	n = l[2] - l[1]
	n = n + l[2] - l[0]
	if n > x:
		print('NO')
	elif (x - n) % 3 == 0:
		print('YES')
	else:
		print('NO')


case = int(input())
for i in range(case):
	(x, y, z, n) = map(int, input().split())
	maxt = max(x, y, z)
	to = x + y + z + n
	if to % 3 == 0 and to / 3 >= maxt:
		print('YES')
	else:
		print('NO')


test = int(input())
for _ in range(test):
	a = []
	a.append(0)
	a.append(0)
	a.append(0)
	(a[0], a[1], a[2], n) = map(int, input().split())
	a.sort()
	if (sum(a) + n) % 3 == 0:
		n -= 2 * a[2] - a[1] - a[0]
		if n < 0 or n % 3 != 0:
			print('NO')
		else:
			print('YES')
	else:
		print('NO')


def solve(a, b, c, n):
	tmp = sorted([a, b, c])
	(a, b, c) = tmp
	n = n - (c - a) - (c - b)
	if n >= 0 and n % 3 == 0:
		print('YES')
	else:
		print('NO')
t = int(input())
for _ in range(t):
	(a, b, c, n) = map(int, input().split())
	solve(a, b, c, n)


def nice(A, n):
	for i in range(1, len(A)):
		if n < 0:
			print('NO')
			return 0
		n -= A[i - 1] - A[i]
		A[i] += A[i - 1] - A[i]
	if n < 0:
		print('NO')
		return 0
	if n % 3 == 0:
		print('YES')
	else:
		print('NO')
	return 0
t = int(input())
while t > 0:
	A = list(map(int, input().split()))
	n = A[len(A) - 1]
	A = A[:-1]
	A.sort(reverse=True)
	nice(A, n)
	t -= 1


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


for _ in range(int(input())):
	A = list(map(int, input().split()))
	a = A[0]
	b = A[1]
	c = A[2]
	n = A[3]
	if max(a, b, c) == a:
		raz = a - b + a - c
	elif max(a, b, c) == b:
		raz = b - a + b - c
	elif max(a, b, c) == c:
		raz = c - b + c - a
	if raz > n:
		print('NO')
	elif (raz - n) % 3 == 0:
		print('YES')
	else:
		print('NO')


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


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


t = int(input())
while t != 0:
	a = list(map(int, input().split(' ')))
	c = a[3]
	a.pop()
	a.sort()
	b = a[2] - a[1] + (a[2] - a[0])
	if b <= c:
		if (c - b) % 3 == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')
	t = t - 1


for _ in range(int(input())):
	(a, b, c, n) = map(int, input().split())
	x = max([a, b, c]) * 3
	s = sum([a, b, c])
	q = x - s
	n = n - q
	if n % 3 == 0 and n >= 0:
		print('YES')
	else:
		print('NO')


def distribute_coins_equally():
	for test in tests_list:
		left_overs = 0
		left_over = ''
		maximum = max(test[0:-1])
		for i in range(amount_of_people_to_distribute):
			left_over = abs(test[i] - maximum)
			left_overs += left_over
		n = test[3]
		n -= left_overs
		if n >= 0:
			if n % 3 == 0:
				print('YES')
			else:
				print('NO')
		else:
			print('NO')
number_of_tests = int(input())
tests_list = []
amount_of_people_to_distribute = 3
for i in range(number_of_tests):
	test = input()
	tests_list.append([int(i) for i in test.split()])
distribute_coins_equally()


for x in range(int(input())):
	(a, b, c, k) = map(int, input().split())
	max1 = max(a, b, c)
	a = max1 - a
	b = max1 - b
	c = max1 - c
	s = a + b + c
	if s <= k:
		k = k - s
		if k % 3 == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


import sys
import queue
from math import sqrt
input = lambda : sys.stdin.readline()

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


t = int(input())
for _ in range(t):
	(a, b, c, n) = list(map(int, input().split()))
	d = max(a, b, c)
	n -= 3 * d - a - b - c
	if n < 0 or n % 3:
		print('NO')
	else:
		print('YES')


def co(s):
	h = 0
	an = 0
	for i in range(len(s) - 1, -1, -1):
		if s[i] != ',':
			an += pow(10, h) * int(s[i])
			h += 1
	return an
t = input()
t = co(t)
for _ in range(t):
	(a, b, c, d) = map(str, input().split())
	a = co(a)
	b = co(b)
	c = co(c)
	d = co(d)
	if (a + b + c + d) % 3:
		print('NO')
	else:
		k = (a + b + c + d) // 3
		A = k - a
		B = k - b
		C = k - c
		if A >= 0 and B >= 0 and (C >= 0) and (A + B + C == d):
			print('Yes')
		else:
			print('NO')


testcases = int(input())
for i in range(testcases):
	(a, b, c, n) = map(int, input().split())
	maxi = max(a, b, c)
	diff_a = maxi - a
	diff_b = maxi - b
	diff_c = maxi - c
	temp = n - (diff_a + diff_b + diff_c)
	if temp < 0:
		print('NO')
	elif temp == 0:
		print('YES')
	elif temp % 3 == 0:
		print('YES')
	else:
		print('NO')


import math
t = int(input())
for _ in range(t):
	(a, b, c, n) = list(map(int, input().split(' ')))
	t = (a + b + c + n) / 3
	if math.floor(t) == t:
		if abs(t - a) + abs(t - b) + abs(t - c) == n:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(a, b, c, n) = map(int, input().split())
	add = a + b + c + n
	maxval = max(a, b, c)
	if add % 3 == 0 and add // 3 >= maxval:
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	(a, b, c, t) = list(map(int, input().split()))
	k = max(a, b, c)
	l = k - a
	m = k - b
	o = k - c
	if l + m + o <= t:
		p = a + b + c + t
		if p % 3 == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


t = int(input())
o = []
c = []
for i in range(t):
	o = list(map(int, input().split()))
	n = o[-1]
	o.pop(-1)
	if n - (max(o) * 3 - sum(o)) >= 0 and (n - (max(o) * 3 - sum(o))) % 3 == 0:
		c.append('YES')
	else:
		c.append('NO')
for i in range(t):
	print(c[i])


def solve():
	(a, b, c, n) = map(int, input().split())
	max_coins = max([a, b, c])
	used_coins = max_coins - a
	used_coins += max_coins - b
	used_coins += max_coins - c
	if n >= used_coins and (n - used_coins) % 3 == 0:
		print('YES')
	else:
		print('NO')

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


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


for _ in range(int(input())):
	a = list(map(int, input().split()))
	x = a[3]
	a.remove(a[3])
	m = max(a)
	s = 0
	for i in range(3):
		s += m - a[i]
	p = x - s
	if p < 0:
		print('NO')
	elif p % 3 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
while t > 0:
	(a, b, c, n) = list(map(int, input().split()))
	s = sum([a, b, c, n])
	if s % 3 == 0:
		l = s // 3
		if a > l or b > l or c > l:
			print('NO')
		else:
			print('YES')
	else:
		print('NO')
	t = t - 1


for _ in range(int(input())):
	arr = [int(x) for x in input().split()]
	kids = sorted(arr[:-1])
	if kids[2] - kids[0] + kids[2] - kids[1] > arr[3]:
		print('NO')
	elif not sum(arr) % 3:
		print('YES')
	else:
		print('NO')


import math, sys
from collections import Counter, defaultdict, deque
from sys import stdin, stdout
input = stdin.readline
lili = lambda : list(map(int, sys.stdin.readlines()))
li = lambda : list(map(int, input().split()))
I = lambda : int(input())
S = lambda : input().strip()
mod = 1000000007
for i in range(I()):
	a = li()
	k = a[:3]
	n = a[-1]
	k.sort(reverse=True)
	(a, b, c) = k
	s = a - b + a - c
	n -= s
	if n >= 0 and n % 3 == 0:
		print('YES')
	else:
		print('NO')


def max(a, b):
	if a > b:
		return a
	return b
t = int(input())
while t > 0:
	l = list(map(int, input().split()))
	m = max(max(l[0], l[1]), max(l[1], l[2]))
	after_updation = []
	for i in range(len(l) - 1):
		after_updation.append(m - l[i])
	for i in range(len(after_updation)):
		if after_updation[i] <= l[3]:
			l[3] -= after_updation[i]
			after_updation[i] = 0
	if sum(after_updation) == 0 and l[3] % 3 == 0:
		print('YES')
	else:
		print('NO')
	t -= 1


t = int(input())
for i in range(t):
	s = list(map(int, input().split()))
	a = s[0]
	b = s[1]
	c = s[2]
	n = s[3]
	ss = int(sum(s) / 3)
	A = max(0, ss - a)
	B = max(0, ss - b)
	C = max(0, ss - c)
	if a + A == b + B and b + B == c + C and (a + b + c + A + B + C == sum(s)):
		print('YES')
	else:
		print('NO')


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


n = int(input())
for i in range(n):
	lst = list(map(int, input().split()))
	brought = lst[-1]
	lst.pop()
	maxx = max(lst)
	if 3 * maxx - (lst[0] + lst[1] + lst[2]) > brought:
		print('NO')
	else:
		remain = brought - (3 * maxx - (lst[0] + lst[1] + lst[2]))
		if remain % 3 == 0:
			print('YES')
		else:
			print('NO')


for x in range(int(input())):
	(a, b, c, n) = map(int, input().split())
	r = (a + b + c + n) % 3
	if r != 0:
		print('NO')
	else:
		s = (a + b + c + n) // 3
		if a > s or b > s or c > s:
			print('NO')
		else:
			print('YES')


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


tests = int(input())
for i in range(tests):
	num = input().split()
	A = int(num[0])
	B = int(num[1])
	C = int(num[2])
	N = int(num[3])
	total = A + B + C + N
	m = total // 3
	if total % 3 == 0:
		if m >= A and m >= B and (m >= C):
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


repetition = int(input())
for num in range(repetition):
	(num_a, num_b, num_c, num_n) = map(int, input().split())
	sum_num = num_a + num_b + num_c + num_n
	quo_rem = divmod(sum_num, 3)
	if quo_rem[1] == 0:
		if quo_rem[0] >= num_a and quo_rem[0] >= num_b and (quo_rem[0] >= num_c):
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


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


import os
TEST_DIR = './tests/'

def main():
	if __file__ == 'run.py':
		tests()
	else:
		submit()

def tests():
	for test_case in os.listdir(TEST_DIR):
		if '.swp' in test_case:
			continue
		tests = []
		expectations = []
		with open(TEST_DIR + test_case, 'r') as f:
			n = int(f.readline())
			for _ in range(n):
				tests.append(tuple(map(int, f.readline().split(' '))))
			for _ in range(n):
				expectations.append(f.readline().strip())
		sub_test = 0
		for ix in range(len(tests)):
			result = collecting_coins(*tests[ix])
			if result == expectations[ix]:
				print(f'{test_case}.{str(sub_test)} passed')
			else:
				print(f'{test_case}.{str(sub_test)} failed')
				print(f'\tResult: {str(result)}')
				print(f'\tExpected: {str(expectations[ix])}\n')
			sub_test += 1

def submit():
	tests = []
	n = int(input())
	for _ in range(n):
		tests.append(tuple(map(int, input().split(' '))))
	for test in tests:
		print(collecting_coins(*test))

def collecting_coins(a, b, c, n):
	sister_coins = [a, b, c]
	hi = max(sister_coins)
	for coins in sister_coins:
		n -= hi - coins
	if n < 0 or n % 3 != 0:
		return 'NO'
	return 'YES'
main()


import math
t = int(input())
for _ in range(t):
	(a, b, c, n) = map(int, input().split(' '))
	k = (n + a + b + c) / 3
	A = k - a
	B = k - b
	C = k - c
	if A >= 0 and B >= 0 and (C >= 0):
		if A - math.floor(A) != 0 or B - math.floor(B) != 0 or C - math.floor(C) != 0:
			print('NO')
		else:
			print('YES')
	else:
		print('NO')


for x in range(int(input())):
	k = 0
	(a, b, c, d) = map(int, input().split())
	if max(a, b, c) == a:
		if d - (a - b) >= 0:
			d = d - (a - b)
			if d - (a - c) >= 0:
				d = d - (a - c)
				k = 1
			else:
				k = 0
				print('NO')
		else:
			k = 0
			print('NO')
	elif max(a, b, c) == b:
		if d - (b - a) >= 0:
			d = d - (b - a)
			if d - (b - c) >= 0:
				d = d - (b - c)
				k = 1
			else:
				k = 0
				print('NO')
		else:
			k = 0
			print('NO')
	elif max(a, b, c) == c:
		if d - (c - a) >= 0:
			d = d - (c - a)
			if d - (c - b) >= 0:
				d = d - (c - b)
				k = 1
			else:
				k = 0
				print('NO')
		else:
			k = 0
			print('NO')
	if k == 1 and d % 3 == 0:
		print('YES')
	elif k != 0:
		print('NO')


for i in range(int(input())):
	(a, b, c, n) = [int(elem) for elem in input().split()]
	m = max(a, b, c)
	n -= m - a
	n -= m - b
	n -= m - c
	(a, b, c) = (m, m, m)
	if n < 0:
		print('NO')
	elif n % 3 == 0:
		print('YES')
	else:
		print('NO')


I = input
n = int(I())
for _ in range(n):
	(a, b, c, m) = map(int, I().split())
	k = max(a, b, c)
	if (a + b + c + m) % 3 == 0 and (a + b + c + m) / 3 >= k:
		print('YES')
	else:
		print('NO')


n = int(input())
ans = []
for i in range(n):
	(a, b, c, n) = map(int, input().split())
	z = sorted([a, b, c])
	if (n - (z[2] - z[1] + z[2] - z[0])) % 3 == 0 and n - (z[2] - z[1] + z[2] - z[0]) >= 0:
		ans.append('YES')
	else:
		ans.append('NO')
print(*ans, sep='\n')


t = int(input())
ans = []
for i in range(t):
	(a, b, c, n) = map(int, input().split())
	m = max(a, b, c)
	s = 0
	if a != m:
		s += m - a
	if b != m:
		s += m - b
	if c != m:
		s += m - c
	if n - s >= 0 and (n - s) % 3 == 0:
		ans.append('YES')
	else:
		ans.append('NO')
for j in range(len(ans)):
	print(ans[j])


t = int(input())
while t:
	t -= 1
	(a, b, c, n) = map(int, input().split())
	(a, b, c) = list(sorted([a, b, c]))
	C = n - (c - a) - (c - b)
	if C >= 0 and C % 3 == 0:
		C = C // 3
		B = n - C - (b - a)
		if B >= 0 and B % 2 == 0:
			B = B // 2
			A = n - C - B
		else:
			print('NO')
			continue
		if A >= 0 and A + B + C == n and (a + A == b + B == c + C):
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


t = int(input())
ansLst = []
for tt in range(t):
	(a, b, c, n) = input().split()
	(a, b, c, n) = (int(a), int(b), int(c), int(n))
	if (a + b + c + n) % 3 == 0 and (a + b + c + n) // 3 >= max(a, b, c):
		ansLst.append('YES')
	else:
		ansLst.append('NO')
for i in range(t):
	print(ansLst[i])


k = int(input())
for y in range(k):
	(a, b, c, n) = map(int, input().split())
	l = [a, b, c]
	l.sort()
	ct = 3 * l[2] - sum(l)
	if n < ct or n % 3 != ct % 3:
		print('NO')
	else:
		print('YES')


t = int(input())
for i in range(t):
	(a, b, c, n) = map(int, input().split(' '))
	arr = [a, b, c]
	arr.sort()
	diff = sum([arr[-1] - e for e in arr])
	if (n - diff) % 3 == 0 and n - diff >= 0:
		print('YES')
	else:
		print('NO')


test_cases = int(input())
for z in range(test_cases):
	(a, b, c, n) = map(int, input().split())
	qnt = (a + b + c + n) // 3
	count = 0
	if (a + b + c + n) % 3 == 0:
		for i in [a, b, c]:
			if int(i) > qnt:
				count += 1
		if count == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


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


t = int(input())
for _ in range(t):
	arr = [int(i) for i in input().split()]
	s = sum(arr)
	if s % 3 == 0:
		app = s // 3
		rem = arr[-1]
		for i in range(len(arr) - 1):
			want = app - arr[i]
			if want < 0:
				rem = -1
				break
			else:
				rem -= want
		if rem == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


def solution(lis):
	(a, b, c, p) = lis.split()
	the_list = [int(a), int(b), int(c)]
	the_list.sort()
	(c, b, a) = the_list
	p = int(p)
	if p >= a - b + (a - c) and (p - (a - b + (a - c))) % 3 == 0:
		return 'YES'
	else:
		return 'NO'
t = int(input())
while t > 0:
	t -= 1
	the_input = input()
	print(solution(the_input))


t = int(input())
for _ in range(t):
	(a, b, c, n) = map(int, input().split())
	d = max(a, b)
	e = max(d, c)
	n = n - (e - a)
	a = a + (e - a)
	n = n - (e - b)
	b = b + (e - b)
	n = n - (e - c)
	c = c + (e - c)
	if n == 0:
		print('YES')
	elif n < 0:
		print('NO')
	elif n > 0 and n % 3 == 0:
		print('YES')
	elif n > 0 and n % 3 != 0:
		print('NO')


for _ in range(int(input())):
	a = list(map(int, input().split()))
	total = sum(a)
	if total % 3 == 0 and max(a[:-1]) <= total // 3:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(a, b, c, n) = map(int, input().split())
	mx = max(max(a, b), c)
	mn = mx - a + mx - b + mx - c
	res = 'NO' if n < mn or (n - mn) % 3 != 0 else 'YES'
	print(res)


for i in range(int(input())):
	li = [int(c) for c in input().split()]
	l = li[:-1]
	l.sort()
	a = l[2] - l[0]
	b = l[2] - l[1]
	if a + b <= li[-1] and (li[-1] - a - b) % 3 == 0:
		print('YES')
	else:
		print('NO')


def main():
	op = ''
	t = int(input())
	for i in range(t):
		ip = [int(item) for item in input().split(' ')]
		x = sum(ip) / 3
		if x.is_integer() and x >= ip[0] and (x >= ip[1]) and (x >= ip[2]):
			op += 'YES\n'
		else:
			op += 'NO\n'
	print(op)
main()


t = int(input())
r = 0
ans = 0
while r < t:
	(a, b, c, n) = input().split()
	a = int(a)
	b = int(b)
	c = int(c)
	n = int(n)
	maxi = max(a, b, c)
	n -= maxi - a
	n -= maxi - b
	n -= maxi - c
	if n >= 0 and n % 3 == 0:
		print('YES')
	else:
		print('NO')
	r = r + 1


n = int(input())
maxx = max
for i in range(n):
	(a, b, c, n) = list(map(int, input(' ').split()))
	if (a != b or a != c) and n == 0:
		print('No')
	else:
		e = maxx(a, b, c)
		e = e - a + e - b + e - c
		if (n - e) % 3 == 0 and n - e >= 0:
			print('Yes')
		else:
			print('No')


import math
for _ in range(int(input())):
	(a, b, c, n) = map(int, input().split())
	A = (n + c + b - 2 * a) / 3
	if math.ceil(A) == A:
		if A >= 0 and a - b + A >= 0 and (a - c + A >= 0):
			print('YES')
			continue
	print('NO')


rr = lambda : input().strip()
rri = lambda : int(rr())
rrm = lambda : [int(x) for x in rr().split()]

def sol():
	(a, b, c, n) = rrm()
	k = max(a, b, c)
	n -= k - a
	n -= k - b
	n -= k - c
	if n < 0:
		return 'NO'
	if n % 3 == 0:
		return 'YES'
	return 'NO'
t = rri()
for _ in range(t):
	ans = sol()
	print(ans)


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


t = int(input())
for _ in range(t):
	(a, b, c, n) = map(int, input().split())
	s_lst = sorted([a, b, c])
	n -= s_lst[-1] - s_lst[0]
	n -= s_lst[-1] - s_lst[1]
	if n >= 0 and n % 3 == 0:
		print('YES')
	else:
		print('NO')


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


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


for _ in range(int(input())):
	l = list(map(int, input().split()))
	ll = l[:3]
	ll.sort()
	temp = ll[2] - l[1]
	ss = sum(ll)
	if temp > l[3]:
		print('NO')
		continue
	else:
		temp = ll[2] * 3
		temp = temp - ss
		if temp > l[3]:
			print('NO')
			continue
		elif (l[3] - temp) % 3 == 0:
			print('YES')
			continue
		else:
			print('NO')


t = int(input())
while t:
	t = t - 1
	(a, b, c, n) = map(int, input().split())
	aa = []
	aa.append(a)
	aa.append(b)
	aa.append(c)
	aa.sort()
	n = n - (aa[2] - aa[0])
	n = n - (aa[2] - aa[1])
	if n % 3 == 0 and n >= 0:
		print('YES')
	else:
		print('NO')


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


import sys
input = sys.stdin.readline

def main():
	t = int(input())
	for _ in range(t):
		(A, B, C, N) = [int(x) for x in input().split()]
		ma = max([A, B, C])
		N -= ma - A + (ma - B) + (ma - C)
		if N % 3 != 0 or N < 0:
			print('NO')
		else:
			print('YES')
main()


n = int(input())
for i in range(n):
	v = list(map(int, input().split()))
	if sum(v) % 3 != 0:
		print('NO')
	else:
		nb = sum(v) / 3
		if nb < v[0] or nb < v[1] or nb < v[2]:
			print('NO')
		else:
			print('YES')


for _ in range(int(input())):
	(a, b, c, n) = [int(i) for i in input().strip().split()]
	if (n + a + c - 2 * b) % 3 != 0:
		print('NO')
	else:
		B = (n + a + c - 2 * b) // 3
		A = b - a + B
		C = b - c + B
		if A < 0 or B < 0 or C < 0:
			print('NO')
		else:
			print('YES')


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


t = int(input())
for i in range(t):
	l = list(map(int, input().split()))
	a = l[0]
	b = l[1]
	c = l[2]
	n = l[3]
	total = a + b + c + n
	if total % 3 != 0:
		print('NO')
		pass
	else:
		f = total // 3
		if a > f or b > f or c > f:
			print('NO')
		else:
			print('YES')


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')

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 Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 10 ** 9 + 7
Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()
for _ in range(int(ri())):
	(a, b, c, n) = Ri()
	summ = a + b + c + n
	if summ % 3 != 0:
		NO()
	else:
		summ = summ // 3
		if a > summ or b > summ or c > summ:
			NO()
		else:
			YES()


t = int(input())
for i in range(t):
	(a, b, c, n) = [int(i) for i in input().split()]
	total = a + b + c + n
	final_each = total // 3
	if a > final_each or b > final_each or c > final_each or (total % 3 != 0):
		print('NO')
	else:
		print('YES')


def solve(A, B, C, N):
	if (A + B + C + N) % 3 == 0:
		if (A + B + C + N) // 3 >= A and (A + B + C + N) // 3 >= B and ((A + B + C + N) // 3 >= C):
			print('YES')
			return 0
		else:
			print('NO')
			return 0
	else:
		print('NO')
t = int(int(input()))
while t != 0:
	(a, b, c, n) = map(int, input().split(' '))
	solve(a, b, c, n)
	t -= 1


t = int(input())
for i in range(t):
	(a, b, c, n) = [int(x) for x in input().split()]
	m = max(a, b, c)
	n -= m - a + (m - b) + (m - c)
	if n % 3 == 0 and n >= 0:
		print('YES')
	else:
		print('No')


import math
for _ in range(int(input())):
	k = input().split()
	c = [int(i) for i in k[:3]]
	m = max(c)
	n = int(k[-1])
	parti = n % 3
	dife = 0
	for j in c:
		dife += m - j
		parti += j % 3
	if parti % 3 != 0:
		print('NO')
	elif n < dife:
		print('NO')
	else:
		print('YES')


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


n = int(input())
for _ in range(n):
	arr = list(map(int, input().split()))
	x = sum(arr) % 3
	if x == 0:
		d = sum(arr) // 3
		m = max(arr[0:3])
		if m > d:
			print('NO')
		else:
			print('YES')
	else:
		print('NO')


t = int(input())
i = 0
l = []
while i < t:
	s = input().split(' ')
	(a, b, c, n) = s
	a = int(a)
	b = int(b)
	c = int(c)
	n = int(n)
	if (a + b + c + n) % 3 == 0 and max(a, b, c) <= (a + b + c + n) / 3:
		l.append('YES')
	else:
		l.append('NO')
	i += 1
for i in l:
	print(i)


from math import *
from sys import stdin, stdout
import itertools
import os
import sys
import threading
from collections import deque, Counter, OrderedDict, defaultdict
from heapq import *
from fractions import Fraction
mod = int(pow(10, 9) + 7)

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

def si():
	return str(input())

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

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

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

def fsi():
	return str(stdin.readline())

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

def fli():
	return list(fmi())
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}

def getKey(item):
	return item[0]

def sort2(l):
	return sorted(l, key=getKey)

def d2(n, m, num):
	return [[num for x in range(m)] for y in range(n)]

def isPowerOfTwo(x):
	return x and (not x & x - 1)

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def ntl(n):
	return [int(i) for i in str(n)]

def powerMod(x, y, p):
	res = 1
	x %= p
	while y > 0:
		if y & 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res
graph = defaultdict(list)
visited = [0] * 1000000
col = [-1] * 1000000

def bfs(d, v):
	q = []
	q.append(v)
	visited[v] = 1
	while len(q) != 0:
		x = q[0]
		q.pop(0)
		for i in d[x]:
			if visited[i] != 1:
				visited[i] = 1
				q.append(i)
		print(x)

def make_graph(e):
	d = {}
	for i in range(e):
		(x, y) = mi()
		if x not in d:
			d[x] = [y]
		else:
			d[x].append(y)
		if y not in d:
			d[y] = [x]
		else:
			d[y].append(x)
	return d

def gr2(n):
	d = defaultdict(list)
	for i in range(n):
		(x, y) = mi()
		d[x].append(y)
	return d

def connected_components(graph):
	seen = set()

	def dfs(v):
		vs = set([v])
		component = []
		while vs:
			v = vs.pop()
			seen.add(v)
			vs |= set(graph[v]) - seen
			component.append(v)
		return component
	ans = []
	for v in graph:
		if v not in seen:
			d = dfs(v)
			ans.append(d)
	return ans

def primeFactors(n):
	s = set()
	while n % 2 == 0:
		s.add(2)
		n = n // 2
	for i in range(3, int(sqrt(n)) + 1, 2):
		while n % i == 0:
			s.add(i)
			n = n // i
	if n > 2:
		s.add(n)
	return s

def find_all(a_str, sub):
	start = 0
	while True:
		start = a_str.find(sub, start)
		if start == -1:
			return
		yield start
		start += len(sub)

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

def dijkstra(edges, f, t):
	g = defaultdict(list)
	for (l, r, c) in edges:
		g[l].append((c, r))
	(q, seen, mins) = ([(0, f, ())], set(), {f: 0})
	while q:
		(cost, v1, path) = heappop(q)
		if v1 not in seen:
			seen.add(v1)
			path = (v1, path)
			if v1 == t:
				return (cost, path)
			for (c, v2) in g.get(v1, ()):
				if v2 in seen:
					continue
				prev = mins.get(v2, None)
				next = cost + c
				if prev is None or next < prev:
					mins[v2] = next
					heappush(q, (next, v2, path))
	return float('inf')

def binsearch(a, l, r, x):
	while l <= r:
		mid = l + (r - 1) // 2
		print(mid)
		if a[mid]:
			return mid
		elif a[mid] > x:
			l = mid - 1
		else:
			r = mid + 1
	return -1
t = ii()
for _ in range(t):
	(a, b, c, n) = mi()
	if (a + b + c + n) % 3 == 0:
		k = (a + b + c + n) // 3
		if k - a < 0 or k - b < 0 or k - c < 0:
			print('NO')
		else:
			print('YES')
	else:
		print('NO')


def solve(a, b, c, n):
	m = max(a, b, c)
	n -= m - a + m - b + m - c
	if n < 0:
		return 'NO'
	if n % 3 == 0:
		return 'YES'
	else:
		return 'NO'
t = int(input())
for _ in range(t):
	(a, b, c, n) = [int(x) for x in input().split()]
	print(solve(a, b, c, n))


t = int(input())
for k in range(t):
	entrada = list(map(int, input().split(' ')))
	n = entrada[3]
	entrada.remove(entrada[3])
	entrada.sort()
	if entrada[0] == entrada[2]:
		if n % 3 == 0:
			print('YES')
		else:
			print('NO')
	elif n > 0:
		falta1 = entrada[2] - entrada[1]
		if n >= falta1:
			entrada[1] += falta1
			n -= falta1
			falta2 = entrada[2] - entrada[0]
			if n >= falta2:
				entrada[0] += falta2
				n -= falta2
				if n % 3 == 0:
					print('YES')
				else:
					print('NO')
			else:
				print('NO')
		else:
			print('NO')
	else:
		print('NO')


n = int(input())
lis = []
mx = 0
for i in range(n):
	(a, b, c, n) = map(int, input().split())
	mx = max(a, b)
	mx = max(mx, c)
	k = 3 * mx - a - b - c
	print(['NO', 'YES'][(n - k) % 3 == 0 and n - k >= 0])


class Collecting_Coins:

	def solve(self, a, b, c, n):
		resMax = max(max(a, b), c)
		if resMax == a:
			requiredCoins = 2 * a - (b + c)
		elif resMax == b:
			requiredCoins = 2 * b - (a + c)
		else:
			requiredCoins = 2 * c - (b + a)
		if n < requiredCoins:
			return 'NO'
		else:
			result = (a + b + c + n) % 3
			if result == 0:
				return 'YES'
		return 'NO'
n = int(input())
for i in range(n):
	(a, b, c, n) = map(int, input().split())
	collectCoins = Collecting_Coins()
	result = collectCoins.solve(a, b, c, n)
	print(result)


t = int(input())
for i in range(t):
	inp = input().split(' ')
	inp = [int(x) for x in inp]
	n = inp[len(inp) - 1]
	del inp[len(inp) - 1]
	inp.sort()
	(a, b) = (inp[2] - inp[0], inp[2] - inp[1])
	if inp[0] == inp[1] and inp[1] == inp[2]:
		if n % 3 == 0:
			print('YES')
			continue
		else:
			print('NO')
			continue
	elif a + b > inp[2]:
		if n - (a + b) >= 0 and (n - (a + b)) % 3 == 0:
			print('YES')
			continue
		else:
			print('NO')
			continue
	elif inp[1] == inp[2]:
		if n - a >= 0 and (n - a) % 3 == 0:
			print('YES')
			continue
		else:
			print('NO')
			continue
	elif a == b:
		if a + b == n:
			print('YES')
			continue
	z = n - (a + b)
	if z % 3 == 0 and z >= 0:
		print('YES')
	else:
		print('NO')


import math
from collections import defaultdict, Counter, deque
INF = float('inf')

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

def primeFactor(n):
	if n % 2 == 0:
		return 2
	i = 3
	while i ** 2 <= n:
		if n % i == 0:
			return i
		i += 1
	return n

def main():
	(a, b, c, n) = map(int, input().split())
	arr = sorted([a, b, c])
	n -= arr[2] - arr[0]
	if n < 0:
		print('NO')
		return
	n -= arr[2] - arr[1]
	if n < 0:
		print('NO')
		return
	if n % 3 == 0:
		print('YES')
	else:
		print('NO')
t = int(input())
for _ in range(t):
	main()


t = int(input())
while t > 0:
	(a, b, c, n) = input().split()
	a1 = int(a)
	b1 = int(b)
	c1 = int(c)
	n = int(n)
	lst = []
	lst.append(a1)
	lst.append(b1)
	lst.append(c1)
	lst.sort()
	n = n - (lst[2] - lst[0])
	n = n - (lst[2] - lst[1])
	if n >= 0 and n % 3 == 0:
		print('YES')
	else:
		print('NO')
	t = t - 1


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


t = int(input())
A = [0] * t
B = [0] * t
C = [0] * t
N = [0] * t
for i in range(t):
	(A[i], B[i], C[i], N[i]) = map(int, input().split())
rs = ['NO'] * t
for i in range(t):
	m = max([A[i], B[i], C[i]])
	s = 3 * m - sum([A[i], B[i], C[i]])
	if (N[i] - s) % 3 == 0 and N[i] - s >= 0:
		rs[i] = 'YES'
for x in rs:
	print(x)


n = int(input())
for i in range(n):
	s = list(map(int, input().split()))
	d = s[:3]
	d = sorted(d)
	c = d[-1] - d[0]
	x = s[-1] - c
	e = d[-1] - d[1]
	y = x - e
	if s[-1] < c + e:
		print('NO')
	elif y % 3 == 0:
		print('YES')
	else:
		print('NO')


a = int(input())
d = []
for i in range(a):
	entered_list = input().split()
	num_list = list(map(int, entered_list))
	d.append(num_list)
for i in d:
	f = max(i[0], i[1], i[2])
	mon = f - i[0] + (f - i[1]) + (f - i[2])
	if i[3] < mon:
		print('NO')
	elif i[3] == mon:
		print('YES')
	elif (i[3] - mon) % 3 == 0:
		print('YES')
	else:
		print('NO')


def abc(a, b, c, n):
	r = a + b + c + n
	if r % 3 != 0:
		return 'NO'
	r = r // 3
	if a > r or b > r or c > r:
		return 'NO'
	return 'YES'
for i in range(int(input())):
	(a, b, c, n) = map(int, input().split())
	print(abc(a, b, c, n))


t = int(input())
for i in range(t):
	abcn = list(map(int, input().split()))
	maximum = max(abcn[0], abcn[1], abcn[2])
	if (abcn[3] - (maximum - abcn[0]) - (maximum - abcn[1]) - (maximum - abcn[2])) % 3 == 0 and abcn[3] - (maximum - abcn[0]) - (maximum - abcn[1]) - (maximum - abcn[2]) >= 0:
		print('YES')
	else:
		print('NO')


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


def ispossible(coins):
	polycarpus = coins.pop(-1)
	tosumto = max(coins)
	for amt in range(len(coins)):
		polycarpus -= tosumto - coins[amt]
		coins[amt] += tosumto - coins[amt]
	return 'YES' if polycarpus % 3 == 0 and polycarpus >= 0 else 'NO'
for _ in range(int(input())):
	print(ispossible(list(map(int, input().rstrip().split()))))


test = int(input())
for t in range(test):
	(a, b, c, n) = map(int, input().split())
	if a <= b:
		if b <= c:
			pass
		else:
			(b, c) = (c, b)
	else:
		(a, b) = (b, a)
		if b <= c:
			pass
		else:
			(b, c) = (c, b)
	if n < 2 * c - b - a:
		print('NO')
	else:
		su = a + b + c + n
		if su % 3 == 0:
			print('YES')
		else:
			print('NO')


t = int(input())
while t > 0:
	(a, b, c, n) = map(int, input().split())
	p = max(a, b, c)
	s = p - a + (p - b) + (p - c)
	if s > n:
		print('NO')
	elif n == s:
		print('YES')
	elif n > s:
		if (n - s) % 3 == 0:
			print('YES')
		else:
			print('NO')
	t -= 1


num = int(input())
for j in range(num):
	i = 0
	ls = []
	(add, arr, Mxm, req, res) = (0, 0, 0, 0, 0)
	l = list(map(int, input().split()))
	n = l[3]
	for i in range(3):
		add += l[i]
		arr = l[i]
		ls.append(arr)
	Mxm = max(ls)
	req = 3 * Mxm - add
	res = n - req
	if req > n:
		print('NO')
	elif res % 3 == 0:
		print('YES')
	else:
		print('NO')
	ls = 0


def cc(a, b, c, n):
	l = []
	l.append(a)
	l.append(b)
	l.append(c)
	l = sorted(l)
	k = l[2] - l[0] + (l[2] - l[1])
	p = n - k
	if p >= 0 and p % 3 == 0:
		print('YES')
	else:
		print('NO')
t = int(input())
for i in range(t):
	(a, b, c, n) = [int(i) for i in input().split()]
	ans = cc(a, b, c, n)
	ans


t = int(input())
while t:
	t -= 1
	(a, b, c, x) = map(int, input().split())
	m = max(a, b, c)
	req = m - a + m - b + m - c
	if req > x or (x - req) % 3 != 0:
		print('NO')
	else:
		print('YES')


el = int(input())
for x in range(el):
	ar = []
	for i in input().split(' '):
		ar.append(int(i))
	m = ar[0]
	if ar[1] > ar[0]:
		m = ar[1]
	if ar[2] > m:
		m = ar[2]
	needed = m - ar[0] + (m - ar[1]) + (m - ar[2])
	if needed > ar[3]:
		print('NO')
	elif (ar[3] - needed) % 3 == 0:
		print('YES')
	else:
		print('NO')


import math
n = int(input())
for i in range(n):
	k = input()
	j = k.split(' ')
	for i in range(4):
		j[i] = int(j[i])
	m = j.pop()
	l = j.index(max(j))
	if l == 1:
		a = abs(abs(j[1] - j[0]) + abs(j[1] - j[2]))
	elif l == 0:
		a = abs(abs(j[0] - int(j[1])) + abs(j[0] - j[2]))
	elif l == 2:
		a = abs(abs(j[2] - j[1] + abs(j[0] - j[2])))
	if (m - a) % 3 == 0 and m - a >= 0:
		print('YES')
	else:
		print('NO')


t = int(input())
l = []
for i in range(t):
	s = input().split()
	l.append(s)
	for j in range(len(l[i])):
		l[i][j] = int(l[i][j])
	n = l[i][3]
	l[i].pop()
	l[i].sort()
	if l[i][2] * 2 - l[i][1] - l[i][0] > n:
		print('NO')
	elif l[i][2] * 2 - l[i][1] - l[i][0] == n:
		print('YES')
	elif (n - l[i][2] * 2 + l[i][1] + l[i][0]) % 3 == 0:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	arr = list(map(int, input().split()))
	maxi = max(arr[0:3])
	acumulado = 0
	for j in range(3):
		acumulado += maxi - arr[j]
	arr[3] -= acumulado
	if arr[3] < 0:
		print('NO')
	elif arr[3] % 3 == 0:
		print('YES')
	else:
		print('NO')


x = int(input())
l = []
for i in range(x):
	l.append(list(map(int, input().split(' '))))
for i in range(x):
	(a, b, c, z) = (l[i][0], l[i][1], l[i][2], l[i][3])
	m = a
	if b > a:
		m = b
	if c > a and c > b:
		m = c
	d1 = abs(a - m)
	d2 = abs(b - m)
	d3 = abs(c - m)
	s = d1 + d2 + d3
	z -= s
	if z >= 0 and z % 3 == 0:
		print('YES')
	else:
		print('NO')


T = int(input())
for t in range(T):
	(A, B, C, N) = map(int, input().split())
	M = max([A, B, C])
	S = 3 * M - sum([A, B, C])
	N -= S
	if N < 0 or N % 3:
		print('NO')
	else:
		print('YES')


q = int(input())
for i in range(q):
	x = [int(i) for i in input().split()]
	s = 0
	n = x[-1]
	del x[-1]
	v = max(x)
	for i in x:
		s += v - i
	if s > n:
		print('NO')
	elif s == n:
		print('YES')
	elif (n - s) % 3 == 0:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(a, b, c, d) = map(int, input().split(' '))
	if d == 0:
		if a == b == c:
			print('YES')
		else:
			print('NO')
	else:
		e = a + b + c + d
		if e % 3 != 0:
			print('NO')
		else:
			f = e // 3
			if f < max(a, b, c):
				print('NO')
				continue
			g = f - a + (f - b) + (f - c)
			if g == d:
				print('YES')
			else:
				print('NO')


from sys import stdin

def solve():
	for _ in range(int(input())):
		(a, b, c, n) = map(int, stdin.readline().split())
		mx = max(a, b, c)
		num = 3 * mx - a - b - c
		if n >= num and (n - num) % 3 == 0:
			print('YES')
		else:
			print('NO')
solve()


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


t = int(input())
for _ in range(t):
	(a, b, c, n) = [int(x) for x in input().split()]
	if (a + b + c + n) % 3:
		print('NO')
	else:
		k = (a + b + c + n) / 3
		x = min(a, b, c)
		y = max(a, b, c)
		if y > k or x + n < k:
			print('NO')
		else:
			print('YES')


t = int(input())
for cas in range(t):
	(a, b, c, n) = map(int, input().split(' '))
	ret = max(a, b, c)
	cal = ret * 3 - a - b - c
	cal = n - cal
	if cal >= 0 and cal % 3 == 0:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	(a, b, c, n) = list(map(int, input().split()))
	m = max(a, b, c)
	y = m - a + (m - b) + (m - c)
	if n < y or (n - y) % 3 != 0:
		print('NO')
	else:
		print('YES')


t = int(input())
for i in range(t):
	s = input().split(' ')
	ans = 'NO'
	a = int(s[0])
	b = int(s[1])
	c = int(s[2])
	n = int(s[3])
	if (a + b + c + n) % 3 == 0:
		z = (a + b + c + n) / 3
		if z >= a and z >= b and (z >= c):
			ans = 'YES'
	print(ans)


n = int(input())
for i in range(n):
	(a, b, c, money) = [int(j) for j in input().split()]
	(a, b, c) = sorted([a, b, c], reverse=True)
	mx_b = a - b
	mx_c = a - c
	if money - mx_b - mx_c < 0:
		print('NO')
	else:
		money = money - mx_c - mx_b
		if money % 3 == 0:
			print('YES')
		else:
			print('NO')


allsum = 0
count = 0
n = int(input())
li = list()
for i in range(n):
	l = list()
	x = input().split()
	for j in x:
		l.append(int(j))
	li.append(l)
for i in li:
	s = sum(i)
	res = 0
	if s % 3 == 0:
		c = s // 3
		for j in i[0:-1]:
			if j <= c:
				res += 1
	if res == 3:
		print('YES')
	else:
		print('NO')


t = int(input())
arr = []
for _ in range(t):
	arr.append(list(map(int, input().strip().split())))
for i in range(t):
	[a, b, c, n] = arr[i]
	if (a + b + c + n) % 3 == 0 and (a + b + c + n) // 3 >= max(a, b, c):
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(a, b, c, n) = [int(s) for s in input().split()]
	maxi = max(a, b, c)
	left = maxi * 3 - (a + b + c)
	if n < left:
		print('NO')
	else:
		n = n - left
		if n % 3 == 0:
			print('YES')
		else:
			print('NO')


import math, itertools, fractions, heapq, collections, bisect, sys, queue, copy
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
mod = 10 ** 9 + 7
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 [int(x) for x in sys.stdin.readline().split()]

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

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

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

def S():
	return input()

def main():
	n = I()
	ans = []
	for _ in range(n):
		(a, b, c, d) = LI()
		(a, b, c) = sorted([a, b, c])
		sm = a + b + c + d
		if sm % 3 == 0 and c - a + c - b <= d:
			ans.append('YES')
		else:
			ans.append('NO')
	for x in ans:
		print(x)
main()


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


for t in range(int(input())):
	(a, b, c, n) = map(int, input().split())
	s = sorted([a, b, c])
	last = n - (s[2] - s[0]) - (s[2] - s[1])
	if last < 0 or last % 3:
		print('NO')
	else:
		print('YES')


t = int(input())
for i in range(0, t):
	(a, b, c, n) = [int(x) for x in input().split()]
	k = max(a, b, c)
	g = 3 * k - (a + b + c)
	if g <= n:
		n = n - g
		if n % 3 == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


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


tests = int(input())
for i in range(tests):
	(a, b, c, n) = map(int, input().strip().split())
	mx = max([a, b, c])
	mn = min([a, b, c])
	arr = [a, b, c]
	arr.remove(mx)
	arr.remove(mn)
	mid = arr[0]
	if mx == mn:
		if n % 3 == 0:
			print('YES')
		else:
			print('NO')
	else:
		one = mx - mn
		two = mx - mid
		n -= one + two
		if n < 0:
			print('NO')
		elif n % 3 == 0:
			print('YES')
		else:
			print('NO')


for _ in [0] * int(input()):
	(*a, d) = map(int, input().split())
	e = sum(a)
	print('YNEOS'[(e + d) % 3 > 0 or d < 3 * max(a) - e::2])


n = int(input())
for i in range(n):
	(a, b, c, k) = list(map(int, input().split()))
	s = a + b + c + k
	if s % 3 != 0:
		print('NO')
		continue
	m = int(s / 3)
	if m < max({a, b, c}):
		print('NO')
		continue
	print('YES')


num = int(input())
inputList = []
for i in range(num):
	raw = input().split(' ')
	(a, b, c, n) = [int(x) for x in raw]
	inputList.append([a, b, c, n])
for (a, b, c, n) in inputList:
	maxNum = max([a, b, c])
	base = maxNum * 3 - (a + b + c)
	if (n - base) % 3 == 0 and n - base >= 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(a, b, c, n) = map(int, input().split())
	if a > b:
		d1 = a - b
		n -= d1
		b += d1
	elif a < b:
		d1 = b - a
		n -= d1
		a += d1
	if a > c:
		d2 = a - c
		n -= d2
	elif a < c:
		d2 = c - a
		n -= 2 * d2
	if n == 0:
		print('YES')
	elif n > 0:
		if n % 3 == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


t = int(input())
b = []
for i in range(t):
	a = input().split()
	b.append(a)
for i in b:
	k = max(int(i[0]), int(i[1]), int(i[2]))
	p = abs(int(i[0]) - k) + abs(int(i[1]) - k) + abs(int(i[2]) - k)
	if p > int(i[3]):
		print('NO')
	elif (int(i[3]) - p) % 3 == 0:
		print('YES')
	else:
		print('NO')


T = int(input())
for _ in range(T):
	(a, b, c, n) = [int(i) for i in input().split()]
	A = sorted([a, b, c])
	thres = 2 * A[-1] - A[0] - A[1]
	if n < thres or (n - thres) % 3:
		print('NO')
	else:
		print('YES')


t = int(input())
while t > 0:
	(a, b, c, n) = map(int, input().split())
	A = (n + b + c - 2 * a) / 3
	B = (n + a + c - 2 * b) / 3
	C = (n + a + b - 2 * c) / 3
	if n == int(A) + int(B) + int(C) and (a + int(A) == b + int(B) == c + int(C) and A >= 0 and (B >= 0) and (C >= 0)):
		print('Yes')
	else:
		print('No')
	t -= 1


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


try:
	for _ in range(int(input())):
		(a, b, c, n) = map(int, input().split())
		d = max(a, b, c)
		d = d - a + (d - b) + (d - c)
		n = n - d
		if n >= 0:
			if n % 3 == 0:
				print('YES')
			else:
				print('NO')
		else:
			print('NO')
except:
	pass


total_test = int(input())
for _ in range(total_test):
	(a, b, c, n) = list(map(int, input().split()))
	totsum = a + b + c + n
	if totsum % 3 == 0:
		dis = totsum // 3
		if a > dis or b > dis or c > dis:
			print('NO')
		else:
			print('YES')
	else:
		print('NO')


from sys import stdin
from os import path
if path.exists('inp.txt'):
	stdin = open('inp.txt', 'r')
q = int(stdin.readline())
for _ in range(q):
	(a, b, c, n) = map(int, stdin.readline().split())
	if (n + b + a + c) % 3 != 0:
		print('No')
	else:
		sum = int((n + a + b + c) / 3)
		print('No' if sum < a or sum < b or sum < c else 'Yes')


for _ in range(int(input())):
	(a, b, c, d) = [int(i) for i in input().split()]
	max1 = max([a, b, c])
	sum = max1 - a + max1 - b + max1 - c
	if d - sum >= 0:
		if (d - sum) % 3 == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


for _ in range(int(input())):
	(a, b, c, n) = [int(x) for x in input().split()]
	maxa = max(a, b, c)
	num = maxa - a + (maxa - b) + (maxa - c)
	n -= num
	if n < 0:
		print('NO')
		continue
	if n % 3:
		print('NO')
	else:
		print('YES')


from sys import stdin, stdout
import math
from itertools import permutations, combinations
from collections import defaultdict

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

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

def I():
	return int(stdin.readline())
P = 1000000007

def main():
	try:
		for _ in range(I()):
			(a, b, c, n) = In()
			ans = (a + b + c + n) / 3
			if ans * 10 % 10 == 0:
				ans = int(ans)
				if a <= ans and b <= ans and (c <= ans):
					print('YES')
				else:
					print('NO')
			else:
				print('NO')
	except:
		pass
main()


def distribute(arr, n):
	big = max(arr)
	val = 0
	for i in arr:
		val += big - i
	n -= val
	if n < 0:
		return 'NO'
	if n % 3 == 0 or n == 0:
		return 'YES'
	return 'NO'
t = int(input())
for i in range(t):
	x = list(map(int, input().rstrip().split()))
	n = x.pop()
	print(distribute(x, n))


t = int(input())
output = []
for _ in range(t):
	(a, b, c, n) = map(int, input().split())
	sum_val = a + b + c + n
	list_val = [a, b, c]
	list_val.sort()
	total_diff = list_val[2] - list_val[0] + (list_val[2] - list_val[1])
	if (n - total_diff) % 3 == 0 and total_diff <= n:
		output.append('YES')
	else:
		output.append('NO')
for x in output:
	print(x)


from sys import stdin
input = stdin.readline
from heapq import heapify, heappush, heappop, heappushpop
from collections import defaultdict as dd, deque as dq, Counter as C
from math import factorial as f, ceil, gcd, sqrt, log
from bisect import bisect_left as bl, bisect_right as br
from itertools import combinations as c, permutations as p
from math import factorial as f, ceil, gcd, sqrt, log
mp = lambda : map(int, input().split())
it = lambda : int(input())
ls = lambda : list(input().strip().split())
mt = lambda r: [list(mp()) for _ in range(r)]
lcm = lambda a, b: a * b // gcd(a, b)

def fibo_n(n):
	return ((1 + sqrt(5)) / 2) ** n / sqrt(5)
mod = 1000000007
for _ in range(it()):
	(*a, b) = list(mp())
	a.sort()
	cureq = a[2] - a[1] + a[2] - a[0]
	if b - cureq >= 0:
		k = b - cureq
		if k % 3 == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


import sys
import math
for i in range(int(input())):
	(a, b, c, n) = map(int, input().split())
	l = [a, b, c]
	l.sort(reverse=True)
	needed = l[0] - l[1] + l[0] - l[2]
	if n - needed >= 0 and (n - needed) % 3 == 0:
		print('YES')
	else:
		print('NO')


i = int(input())

def distribution(i):
	for j in range(0, i):
		total = 0
		list1 = [input().split()]
		for i in range(0, len(list1[0])):
			list1[0][i] = int(list1[0][i])
		for ele in range(0, len(list1[0])):
			total = total + list1[0][ele]
		if total % 3 == 0 and list1[0][0] <= total / 3 and (list1[0][1] <= total / 3) and (list1[0][2] <= total / 3):
			print('YES')
		else:
			print('NO')
distribution(i)


from math import *
sInt = lambda : int(input())
mInt = lambda : map(int, input().split())
lInt = lambda : list(map(int, input().split()))
t = sInt()
for _ in range(t):
	(a, b, c, n) = mInt()
	m = max(a, b, c)
	ans = n - (3 * m - (a + b + c))
	if ans % 3 == 0 and ans >= 0:
		print('Yes')
	else:
		print('No')


for _ in range(int(input())):
	li = list(map(int, input().split()))
	if sum(li) % 3 == 0:
		k = sum(li) // 3
		if k >= li[0] and k >= li[1] and (k >= li[2]):
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


t = int(input())
while t > 0:
	l = list(map(int, input().split()))
	a = l[0]
	b = l[1]
	c = l[2]
	n = l[3]
	sum = a + b + c + n
	if sum % 3 == 0 and a <= sum / 3 and (b <= sum / 3) and (c <= sum / 3):
		print('YES')
	else:
		print('NO')
	t = t - 1


for _ in range(int(input())):
	a = list(map(int, input().split()))
	b = sorted(a[:-1])
	x = 2 * b[2] - b[1] - b[0]
	if a[3] < x:
		print('NO')
	elif (a[3] - x) % 3 == 0:
		print('YES')
	else:
		print('NO')


import sys

def main():
	for tc in range(int(input())):
		(a, b, c, n) = get_ints()
		x = a + b + c + n
		if x % 3 != 0:
			print('NO')
		else:
			y = max(a, b, c)
			if x // 3 >= y:
				print('YES')
			else:
				print('NO')
get_array = lambda : list(map(int, sys.stdin.readline().split()))
get_ints = lambda : map(int, sys.stdin.readline().split())
input = lambda : sys.stdin.readline().strip()
main()


for _ in range(int(input())):
	arr = [int(i) for i in input().split()]
	index = arr.index(max(arr[:-1]))
	for (i, value) in enumerate(arr[:-1]):
		if i != index:
			l = arr[index] - arr[i]
			arr[i] += l
			arr[-1] -= l
	if arr[-1] < 0 or arr[-1] % 3 != 0:
		print('NO')
	else:
		print('YES')


t = int(input())
lines = []
for i in range(int(t)):
	lines.append(input().split())
for i in range(t):
	line = lines[i]
	a = int(line[0])
	b = int(line[1])
	c = int(line[2])
	n = int(line[3])
	a_2 = max(a, b, c) - a
	b_2 = max(a, b, c) - b
	c_2 = max(a, b, c) - c
	if a_2 + b_2 + c_2 > n:
		print('NO')
	elif (a + b + c + n) % 3 == 0:
		print('YES')
	else:
		print('NO')


from sys import stdin as cin, stdout as cout
get = cin.readline
end = cout.flush

def put(x):
	cout.write(str(x))
tc = int(get())
for _ in range(tc):
	(a, b, c, n) = map(int, get().split())
	k = (a + b + c + n) // 3
	if (a + b + c + n) % 3 != 0:
		put('NO\n')
	elif k - a >= 0 and k - b >= 0 and (k - c >= 0):
		put('YES\n')
	else:
		put('NO\n')
end()


for _ in range(int(input())):
	(a, b, c, n) = map(int, input().split())
	s = sorted([a, b, c], reverse=True)
	n -= s[0] - s[1]
	n -= s[0] - s[2]
	if n >= 0 and n % 3 == 0:
		print('YES')
	else:
		print('NO')


n = int(input())
for _ in range(n):
	inp_l = [int(e) for e in input().split()]
	coins = inp_l[3]
	A = min(min(inp_l[0], inp_l[1]), min(inp_l[2], inp_l[1]))
	B = max(max(min(inp_l[0], inp_l[1]), min(inp_l[2], inp_l[1])), max(min(inp_l[0], inp_l[1]), min(inp_l[0], inp_l[2])))
	C = max(max(inp_l[0], inp_l[1]), max(inp_l[2], inp_l[1]))
	coins -= C - A
	coins -= C - B
	if coins < 0:
		print('NO')
	elif not coins % 3:
		print('YES')
	else:
		print('NO')


n = int(input())
while n > 0:
	(a, b, c, d) = map(int, input().split())
	li = [a, b, c]
	e = (sum(li) + d) / 3
	if (a + b + c + d) % 3 == 0 and e >= max(li):
		print('YES')
	else:
		print('NO')
	n -= 1


t = int(input())
list1 = [list(map(int, input().split())) for _ in range(t)]
for x in range(t):
	list2 = sorted(list1[x][:3])
	diff = abs(list2[0] - list2[2]) + abs(list2[1] - list2[2])
	if (list1[x][3] - diff) % 3 == 0 and list1[x][3] - diff >= 0:
		print('YES')
	else:
		print('NO')


t = int(input())
while t > 0:
	t = t - 1
	(a, b, c, n) = [int(_) for _ in input().split()]
	m = max(a, b, c)
	r = m - a + m - b + m - c
	if r > n or (n - r) % 3 != 0:
		print('NO')
	else:
		print('YES')


t = int(input())
while t > 0:
	t -= 1
	(a, b, c, n) = [int(k) for k in input().split()]
	A = (b + c + n - 2 * a) / 3
	AValid = A >= 0 and A <= n and A.is_integer()
	B = (a + c + n - 2 * b) / 3
	BValid = B >= 0 and B <= n and B.is_integer()
	C = (b + a + n - 2 * c) / 3
	CValid = C >= 0 and C <= n and C.is_integer()
	print('YES' if AValid and BValid and CValid else 'NO')


for _ in range(int(input())):
	X = [int(x) for x in input().split()]
	li = X[:3]
	m = max(li)
	li.remove(max(li))
	s = sum(li)
	rem = X[3] - 2 * m + s
	if rem < 0:
		print('NO')
	elif rem % 3 == 0:
		print('YES')
	else:
		print('NO')


i = int(input())
co = 0
y = 'YES'
n = 'NO'
collect = []
while co < i:
	(a, b, c, d) = input().split()
	p = int(a)
	q = int(b)
	r = int(c)
	l = [p, q, r]
	l.sort()
	need = 2 * l[2] - l[0] - l[1]
	if int(d) == need:
		collect.append(y)
	elif int(d) > need:
		have = int(d) - need
		if have % 3 == 0:
			collect.append(y)
		else:
			collect.append(n)
	else:
		collect.append(n)
	co += 1
for z in collect:
	print(z)


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


T = int(input())
for _ in range(0, T):
	(a, b, c, n) = map(int, input().split())
	tot = a + b + c + n
	rem = tot // 3
	if tot % 3 == 0 and rem >= a and (rem >= b) and (rem >= c):
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	inp = list(map(int, input().split()))
	(a, b, c, n) = (inp[0], inp[1], inp[2], inp[3])
	del inp[-1]
	inp.sort()
	coins_left = n - (inp[2] - inp[1]) - (inp[2] - inp[0])
	if coins_left < 0:
		print('NO')
	elif coins_left % 3 == 0:
		print('YES')
	else:
		print('NO')


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


import math
for _ in range(int(input())):
	l1 = list(map(int, input().split()))
	n = l1.pop()
	l1.sort()
	a = l1.pop(0)
	b = l1.pop(0)
	c = l1.pop(0)
	if a == b and b == c:
		if n % 3 == 0:
			print('YES')
		else:
			print('NO')
	else:
		x1 = c - a
		x2 = c - b
		if x1 + x2 <= n:
			if (n - x1 - x2) % 3 == 0:
				print('YES')
			else:
				print('NO')
		else:
			print('NO')


t = int(input())
for _ in range(t):
	(a, b, c, n) = input().split(' ')
	a = int(a)
	b = int(b)
	c = int(c)
	n = int(n)
	maxVal = max(a, b, c)
	n -= 3 * maxVal - (a + b + c)
	if n >= 0 and n % 3 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for x in range(t):
	[a, b, c, n] = list(map(int, input().split()))
	if 3 * max(a, b, c) - a - b - c > n:
		print('NO')
		continue
	if (n + a + b + c) % 3 == 0:
		print('YES')
	else:
		print('NO')


tc = int(input())
for kj in range(tc):
	l = input().split(' ')
	for k in range(len(l)):
		l[k] = int(l[k])
	s = l[0:3]
	s.sort(reverse=True)
	a = s[0] - s[1]
	b = s[0] - s[2]
	fg = l[3] - (a + b)
	if fg % 3 == 0 and fg >= 0:
		print('YES')
	else:
		print('NO')


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


def calc(a, b, c, n):
	A = sorted([a, b, c])
	delta = A[2] - A[1] + (A[2] - A[0])
	if n < delta:
		return 'NO'
	if (n - delta) % 3 == 0:
		return 'YES'
	return 'NO'
N = int(input())
cases = []
for _ in range(N):
	(a, b, c, n) = map(int, input().split())
	cases.append([a, b, c, n])
for case in cases:
	print(calc(case[0], case[1], case[2], case[3]))


for _ in range(int(input())):
	(a, b, c, d) = map(int, input().split())
	l = [a, b, c]
	l.sort()
	d = d - 2 * l[2] + l[0] + l[1]
	if d < 0:
		print('NO')
		continue
	print('YES' if d % 3 == 0 else 'NO')


t = int(input())
s = []
for njng in range(0, t):
	x = input()
	xx = x.split()
	j = [int(xx[0]), int(xx[1]), int(xx[2])]
	n = int(xx[3])
	j.sort()
	n = n - (j[2] - j[0]) - (j[2] - j[1])
	if n < 0:
		s.append('NO')
	elif n == 0:
		s.append('YES')
	elif n % 3 == 0:
		s.append('YES')
	else:
		s.append('NO')
for i in s:
	print(i)


def inplst():
	return list(map(int, input().split()))
for _ in range(int(input())):
	l = inplst()
	if sum(l) % 3 == 0 and max(l[:-1]) <= sum(l) // 3:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(a, b, c, n) = list(map(int, input().split()))
	maxx = max([a, b, c])
	A = maxx - a
	B = maxx - b
	C = maxx - c
	n = n - A - B - C
	if n < 0:
		print('NO')
	elif n % 3 == 0:
		print('YES')
	else:
		print('NO')


size = int(input())
for i in range(0, size):
	n = []
	c = 0
	num = input().split(' ')
	last = int(num[len(num) - 1])
	for j in range(0, len(num) - 1):
		n.append(int(num[j]))
	maximum = max(n)
	for l in range(0, len(n)):
		c += maximum - n[l]
	if (last - c) % 3 == 0 and last - c >= 0:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(*A, n) = map(int, input().split())
	s = sum(A) + n
	A.sort()
	n = n - (A[2] - A[0])
	n = n - (A[2] - A[1])
	if n >= 0 and n % 3 == 0:
		print('yes')
	else:
		print('no')


t = int(input())
for i in range(t):
	(a, b, c, n) = [int(i) for i in input().split()]
	arr = [a, b, c]
	arr.sort()
	if a == b == c and n % 3 == 0:
		print('YES')
		continue
	dif1 = arr[2] - arr[1]
	if dif1 > n:
		print('NO')
		continue
	n -= dif1
	arr[1] += dif1
	dif2 = arr[2] - arr[0]
	if dif2 > n:
		print('NO')
		continue
	n -= dif2
	arr[0] += dif2
	if arr[2] == arr[1] == arr[0]:
		if n % 3 == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


n = int(input())
L = []
for i in range(n):
	(a, b, c, x) = map(int, input().split())
	s = a + b + c + x
	m = max(a, b, c)
	if s % 3 == 0 and m * 3 <= s:
		L.append('YES')
	else:
		L.append('NO')
for i in L:
	print(i)


k = int(input(''))
count = 1
while count <= k:
	count = count + 1
	(a, b, c, n) = [int(x) for x in input('').split()]
	if a > b:
		if a > c:
			greatest = a
		else:
			greatest = c
	elif b > c:
		greatest = b
	else:
		greatest = c
	sub = greatest - a + (greatest - b) + (greatest - c)
	res = n - sub
	if sub > n:
		print('NO')
	elif res % 3 == 0:
		print('YES')
	else:
		print('NO')


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


for T in range(int(input())):
	(A, B, C, N) = map(int, input().split())
	a = (B + C + N - 2 * A) / 3
	b = (A + C + N - 2 * B) / 3
	c = (B + A + N - 2 * C) / 3
	if a % 1 == 0 and b % 1 == 0 and (c % 1 == 0) and (a >= 0) and (b >= 0) and (c >= 0):
		if A + a == B + b == C + c:
			print('YES')
	else:
		print('NO')


te = int(input())
while te > 0:
	te -= 1
	(a, b, c, n) = list(map(int, input().split()))
	totalCoins = a + b + c + n
	m = -1
	m = max(a, max(b, c))
	equalizedCoins = m - a + m - b + m - c
	if n - equalizedCoins < 0:
		print('NO')
	elif (n - equalizedCoins) % 3 == 0:
		print('YES')
	else:
		print('NO')


n = int(input())
result = []
for i in range(n):
	(a, b, c, n) = list(map(int, input().split(' ')))
	summ = a + b + c + n
	if n == 0:
		if a == b == c:
			result.append('YES')
		else:
			result.append('NO')
	elif summ % 3 == 0:
		A = summ / 3 - a
		B = summ / 3 - b
		C = summ / 3 - c
		if (A >= 0) & (B >= 0) & (C >= 0) & (A + B + C == n):
			result.append('YES')
		else:
			result.append('NO')
	else:
		result.append('NO')
for i in result:
	print(i)


t = int(input().strip())
for _ in range(t):
	nums = [int(x) for x in input().split(' ')]
	n = nums[3]
	max_num = max(nums[0:3])
	for i in range(3):
		if nums[i] != max_num:
			n -= max_num - nums[i]
	if n < 0:
		print('NO')
		continue
	if n % 3 != 0:
		print('NO')
		continue
	else:
		print('YES')
		continue


t = int(input())
for i in range(t):
	(a, b, c, n) = [int(a) for a in input().split()]
	m = max(a, b, c)
	L = a + b + c
	minn = m - a + (m - b) + (m - c)
	if n < minn:
		print('NO')
	elif n >= minn and (n - minn) % 3 == 0:
		print('YES')
	else:
		print('NO')


def distribute(a, b, c, n):
	m = max(a, b, c)
	A = m - a
	B = m - b
	C = m - c
	if n - (A + B + C) < 0:
		return 'NO'
	elif (n - (A + B + C)) % 3:
		return 'NO'
	else:
		return 'YES'

def main():
	t = int(input())
	outcome = list()
	for i in range(t):
		(a, b, c, n) = map(int, input().split())
		outcome.append(distribute(a, b, c, n))
	print('\n'.join(outcome))
main()


x = int(input())
for i in range(0, x):
	c = list(map(int, input().split()))
	d = c.pop()
	c.sort()
	e = c[2] - c[1]
	f = c[2] - c[0]
	d = d - e - f
	if d >= 0 and d % 3 == 0:
		print('YES')
	else:
		print('NO')


import math

def can_be_split(a, b, c, n):
	y = (c + a + n - 2 * b) / 3
	z = a + n - 2 * y - b
	x = n - y - z
	return x + y + z == n and x >= 0 and (y >= 0) and (z >= 0) and (math.ceil(x) == int(x)) and (math.ceil(y) == int(y)) and (math.ceil(z) == int(z))
for _ in range(int(input())):
	(a, b, c, n) = map(int, input().split())
	print('YES' if can_be_split(a, b, c, n) else 'NO')


n = int(input())
cases = [list(map(int, input().split())) for _ in range(n)]
for case in cases:
	sm = 0
	mx = max(case[0], case[1], case[2])
	for i in case[:3]:
		sm += mx - i
	case[3] -= sm
	if case[3] == 0:
		print('YES')
	elif case[3] % 3 == 0 and case[3] > 0:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(*l, n) = map(int, input().split())
	(a, b, c) = sorted(l)
	a = c - a
	b = c - b
	k = n - (a + b)
	if k > 2 and k % 3 == 0 or k == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(a, b, c, n) = input().split()
	f = max(int(a), int(b), int(c))
	f2 = f - int(a) + f - int(b) + f - int(c)
	n2 = int(n) - f2
	n2 = n2 // 3 * 3
	if n2 + f2 == int(n) and n2 >= 0:
		print('YES')
	else:
		print('NO')


def find(max, x, y, n):
	x1 = max - x
	n = n - x1
	if n < 0:
		return 'NO'
	y1 = max - y
	n = n - y1
	if n < 0:
		return 'NO'
	if n % 3 == 0:
		return 'YES'
	else:
		return 'NO'
t = int(input())
while t > 0:
	(a, b, c, n) = map(int, input().split(' '))
	m = max(a, b, c)
	if a == m:
		print(find(a, b, c, n))
	elif b == m:
		print(find(b, a, c, n))
	elif c == m:
		print(find(c, b, a, n))
	t -= 1


test = int(input())
while test > 0:
	test -= 1
	(a, b, c, x) = map(int, input().split())
	maxi = max(a, b, c)
	lagbe = maxi - a + maxi - b + maxi - c
	if lagbe > x:
		print('NO\n')
		continue
	x -= lagbe
	if x % 3 == 0:
		print('YES\n')
	else:
		print('NO\n')


for nt in range(int(input())):
	(a, b, c, n) = list(map(int, input().split()))
	if (a + b + c + n) % 3 != 0:
		print('NO')
		continue
	v = (a + b + c + n) // 3
	if a > v or b > v or c > v:
		print('NO')
		continue
	print('YES')


for _ in range(int(input())):
	(a, b, c, n) = list(map(int, input().split()))
	sis = sorted([a, b, c])
	tot = 2 * sis[2] - sum(sis[:2])
	if tot > n:
		print('NO')
		continue
	n -= tot
	if n % 3 == 0:
		print('YES')
	else:
		print('NO')


import copy
import sys
from collections import defaultdict, Counter

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

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

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

def print(arg, *argv, end=None):
	sys.stdout.write(str(arg))
	for i in argv:
		sys.stdout.write(' ' + str(i))
	sys.stdout.write(end) if end else sys.stdout.write('\n')

def GCD(x, y):
	return GCD(y, x % y) if y else x

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

def modInv(s, mod):
	return modPow(s, mod - 2, mod)

def solve():
	t = 1
	t = int(input())
	while t:
		t -= 1
		(a, b, c, n) = mapi()
		res = (a + b + c + n) // 3
		ans = max(a, b, c)
		if (a + b + c + n) % 3 == 0 and 3 * ans <= a + b + c + n:
			print('YES')
		else:
			print('NO')
solve()


for i in range(int(input())):
	a = list(map(int, input().split()))
	(x, y, z) = (a[0], a[1], a[2])
	n = a[3]
	ma = max([x, y, z])
	mi = min([x, y, z])
	sr = sum([x, y, z]) - mi - ma
	n -= ma - sr + ma - mi
	if n >= 0 and n % 3 == 0:
		print('YES')
	else:
		print('NO')


res = ''
for _ in range(int(input())):
	(a, b, c, n) = map(int, input().split())
	avg = (a + b + c + n) / 3
	if avg % 1 != 0 or a > avg or b > avg or (c > avg):
		res += 'NO\n'
	else:
		res += 'YES\n'
print(res)


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


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


t = int(input())
for T in range(t):
	l = [int(x) for x in input().split()]
	if sum(l) % 3 == 0 and max(l[:-1]) <= sum(l) / 3:
		print('YES')
	else:
		print('NO')


def Sol(a, b, c, n):
	temp = [a, b, c]
	temp.sort()
	l = n - (temp[2] - temp[1]) - (temp[2] - temp[0])
	if l % 3 == 0 and l >= 0:
		return 'YES'
	else:
		return 'NO'
for i in range(int(input())):
	t = input().split(' ')
	print(Sol(int(t[0]), int(t[1]), int(t[2]), int(t[3])))


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


import os, sys, math, random

def solve(a, b, c, n):
	s = a + b + c + n
	if s % 3 != 0:
		return 'NO'
	sa = s / 3
	if a > sa or b > sa or c > sa:
		return 'NO'
	return 'YES'
t = int(input())
for _ in range(t):
	(a, b, c, n) = map(int, input().split())
	print(solve(a, b, c, n))


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


t = int(input())
ans = []
for i in range(t):
	o = 'NO'
	(a, b, c, n) = map(int, input().split())
	(a, b, c) = sorted([a, b, c])
	t = n - (c - a + (c - b))
	if t >= 0 and t % 3 == 0:
		o = 'YES'
	ans.append(o)
	print(o)


import sys
t = int(sys.stdin.readline().rstrip())
for _ in range(t):
	inp = list(map(int, sys.stdin.readline().rstrip().split()))
	nums = inp[:3]
	n = inp[3]
	nums.sort()
	n -= nums[2] - nums[0]
	n -= nums[2] - nums[1]
	if n < 0:
		print('NO')
		continue
	if n % 3 != 0:
		print('NO')
		continue
	print('YES')


t = int(input())
for i in range(t):
	(a, b, c, d) = [int(x) for x in input().split(' ')]
	t = max(a, b, c)
	s = t - a + (t - b) + (t - c)
	if d < s:
		print('NO')
	elif (d - s) % 3 == 0:
		print('YES')
	else:
		print('NO')


def collecting_coins():
	num_q = int(input())
	count = 0
	questions = []
	while count < num_q:
		question = input().split(' ')
		for i in range(0, len(question)):
			question[i] = int(question[i])
		questions.append(question)
		count += 1
	for (idx, q) in enumerate(questions):
		if sum(q) % 3 == 0 and sum(q) / 3 >= max(q[:3]):
			print('YES')
		else:
			print('NO')
collecting_coins()


def solve(n, a, b, c):
	s = n + a + b + c
	if s % 3 == 0 and s // 3 >= max([a, b, c]):
		print('YES')
	else:
		print('NO')

def main():
	tc = int(input())
	for _ in range(tc):
		(a, b, c, n) = [int(x) for x in input().split()]
		solve(n, a, b, c)
main()


t = int(input())
while t:
	l = [int(x) for x in input().split()]
	x = sum(l)
	if x % 3 == 0:
		d = x // 3
		if l[0] > d or l[1] > d or l[2] > d:
			print('NO')
		else:
			p = d - l[0]
			q = d - l[1]
			r = d - l[2]
			if p + q + r == l[3]:
				print('YES')
			else:
				print('NO')
	else:
		print('NO')
	t -= 1


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


t = int(input())
for _ in range(t):
	sisters = list(map(int, input().split()))
	n = sisters[3]
	sisters = sisters[:-1]
	to_top = 0
	for x in sisters:
		to_top += max(sisters) - x
	if n >= to_top:
		if (n - to_top) % 3 == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


def check():
	inp = input().split()
	(a, b, c, n) = (int(inp[0]), int(inp[1]), int(inp[2]), int(inp[3]))
	(x, z) = (max(a, b, c), min(a, b, c))
	y = a + b + c - (x + z)
	sub = n - (x - z + (x - y))
	res = sub % 3
	if sub < 0 or res > 0:
		print('No')
	else:
		print('Yes')
m = input()
for i in range(int(m)):
	check()


def after_dist(a, b, c, n):
	m = max([a, b, c])
	cns = m - a + (m - b) + (m - c)
	if n < cns:
		return -1
	else:
		return n - cns

def coins(a, b, c, n):
	a = after_dist(a, b, c, n)
	if a == -1:
		return 'NO'
	if a % 3 == 0:
		return 'YES'
	return 'NO'
t = int(input())
for _ in range(t):
	(a, b, c, n) = [int(x) for x in input().split()]
	print(coins(a, b, c, n))


inp = input
li = list
iinp = lambda : int(inp())
ent = lambda : map(int, inp().split())
lient = lambda : [int(i) for i in inp().split()]
li0 = lambda x: [0 for i in range(x)]
stent = lambda : [i for i in inp()]
ma = max
ab = abs
t = iinp()
for _ in range(t):
	(a, b, c, n) = ent()
	m = ma(a, ma(b, c)) * 3
	n -= ab(a + b + c - m)
	if n == 0:
		print('YES')
	elif n % 3 == 0 and n > 0:
		print('YES')
	else:
		print('NO')


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


t = int(input())
for i in range(t):
	(a, b, c, d) = map(int, input().split())
	aa = max(a, b, c) - a
	bb = max(a, b, c) - b
	cc = max(a, b, c) - c
	if (d - aa - bb - cc) % 3 == 0 and d - aa - bb - cc >= 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	l = list(map(int, input().split()))
	s = sum(l)
	k = s // 3
	c = 0
	if s % 3 == 0:
		for i in range(0, len(l) - 1):
			if l[i] < k:
				c += k - l[i]
		if c == l[-1]:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


for _ in range(int(input())):
	l = list(map(int, input().split()))
	n = l[-1]
	l.remove(n)
	x = 0
	for i in l:
		x += max(l) - i
	if x <= n:
		n -= x
		if n % 3 == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


T = int(input())
for t in range(0, T):
	given = list(map(int, input().split()))
	sisters = given[0:3]
	n = given[3]
	s = 0
	m = max(sisters)
	for element in sisters:
		s = s + (m - element)
	if s <= n and (n - s) % 3 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(a, b, c, n) = map(int, input().split())
	l = [a, b, c]
	l.sort()
	l[0] = l[-1] - l[0]
	l[1] = l[-1] - l[1]
	d = l[0] + l[1]
	if n >= d:
		if (n - d) % 3 == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


INF = 10 ** 10

def main():
	li = get_list()
	(li, n) = (li[:3], li[3])
	li.sort(reverse=True)
	(a, b, c) = li
	n -= 2 * a - b - c
	if n >= 0 and n % 3 == 0:
		print('YES')
	else:
		print('NO')
import sys
from collections import defaultdict, Counter
from bisect import bisect_left, bisect_right
import math
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
out = []
get_int = lambda : int(input())
get_list = lambda : list(map(int, input().split()))
[main() for _ in range(int(input()))]
print(*out, sep='\n')


from sys import stdin, stdout
n = int(stdin.readline())
a = []
for j in range(n):
	a.append([int(x) for x in stdin.readline().split()])
for j in range(n):
	if (a[j][0] + a[j][1] + a[j][2] + a[j][3]) % 3 == 0 and (a[j][0] + a[j][1] + a[j][2] + a[j][3]) // 3 >= a[j][0] and ((a[j][0] + a[j][1] + a[j][2] + a[j][3]) // 3 >= a[j][1]) and ((a[j][0] + a[j][1] + a[j][2] + a[j][3]) // 3 >= a[j][2]):
		print('YES')
	else:
		print('NO')


for _ in ' ' * int(input()):
	(a, b, c, n) = map(int, input().split())
	x = n - (3 * max(a, b, c) - (a + b + c))
	print('NO' if x < 0 or x % 3 else 'YES')


n = int(input())
for _ in range(n):
	c = list(map(int, input().split()))
	s = sum(c)
	if s % 3 == 0:
		a = s / 3
		if c[0] <= a and c[1] <= a and (c[2] <= a):
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


import sys
import math
import heapq
import collections

def inputnum():
	return int(input())

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

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

def inputstring():
	return [x for x in input()]

def inputstringnum():
	return [ord(x) - ord('a') for x in input()]

def inputmatrixchar(rows):
	arr2d = [[j for j in input().strip()] for i in range(rows)]
	return arr2d

def inputmatrixint(rows):
	arr2d = []
	for _ in range(rows):
		arr2d.append([int(i) for i in input().split()])
	return arr2d
t = int(input())
for q in range(t):
	(A, B, C, n) = inputnums()
	a = [A, B, C]
	a.sort()
	if a[2] - a[0] + a[2] - a[1] <= n and (a[0] + a[1] + a[2] + n) % 3 == 0:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	l = list(map(int, input().split()))
	m = max(l[:-1])
	n = l[-1]
	n = n - (m - l[0])
	n = n - (m - l[1])
	n = n - (m - l[2])
	if n % 3 == 0 and n >= 0:
		print('YES')
	else:
		print('NO')


nt = int(input())
for q in range(nt):
	(p, q, r, n) = map(int, input().split())
	s = p + q + r + n
	l = [p, q, r]
	l.sort()
	a = l[0]
	b = l[1]
	c = l[2]
	sum = 0
	s = str(s)
	for i in s:
		i = int(i)
		sum += i
	if sum % 3 == 0 and 2 * c - (a + b) <= n:
		print('YES')
	else:
		print('NO')


n = int(input())
while n > 0:
	(x, y, z, t) = map(int, input().split())
	A = max(x, y, z)
	sum = x + y + z + t
	if sum % 3 == 0 and (x + y + z + t) // 3 >= A:
		print('YES')
	else:
		print('NO')
	n -= 1


t = int(input())
for qwerty in range(t):
	(a, b, c, n) = input().split()
	(a, b, c, n) = (int(a), int(b), int(c), int(n))
	(m1, m2, m3) = (0, 0, 0)
	m1 = max(a, b, c)
	m3 = min(a, b, c)
	if a == m1 and b == m3:
		m2 = c
	elif a == m1 and c == m3:
		m2 = b
	elif b == m1 and c == m3:
		m2 = a
	elif b == m1 and a == m3:
		m2 = c
	elif c == m1 and a == m3:
		m2 = b
	elif c == m1 and b == m3:
		m2 = a
	s = 0
	s = m1 - m2
	s += m1 - m3
	if s > n:
		print('NO')
	if s == n:
		print('YES')
	if s < n:
		n -= s
		if n % 3 == 0:
			print('YES')
		else:
			print('NO')


T = int(input())
for kase in range(T):
	(a, b, c, n) = [int(x) for x in input().split()]
	v = sorted([a, b, c])
	t = v[2] - v[1] + v[2] - v[0]
	if n >= t and (n - t) % 3 == 0:
		print('YES')
	else:
		print('NO')


import sys
t = int(input())
for i in range(t):
	(a, b, c, n) = map(int, sys.stdin.readline().split())
	if max(a, b, c) == a:
		maxi = a
		mid = max(b, c)
		mini = min(b, c)
	elif max(a, b, c) == b:
		maxi = b
		mid = max(a, c)
		mini = min(a, c)
	else:
		maxi = c
		mid = max(a, b)
		mini = min(b, a)
	res = maxi - mid + maxi - mini
	n -= res
	if n >= 0 and n % 3 == 0:
		print('YES')
	else:
		print('NO')


iters = int(input())
for i in range(iters):
	(a, b, c, n) = input().split()
	(a, b, c, n) = (int(a), int(b), int(c), int(n))
	m = max(a, b, c)
	free = n - (m - a) - (m - b) - (m - c)
	if free >= 0 and free % 3 == 0:
		print('YES')
	else:
		print('NO')


import sys
T = int(sys.stdin.readline())
for _ in range(T):
	(a, b, c, n) = map(int, sys.stdin.readline().split())
	if not (a + b + c + n) % 3 and max(a, b, c) <= (a + b + c + n) // 3:
		print('YES')
	else:
		print('NO')


save = []
for i in range(int(input())):
	(a, b, c, n) = input().split()
	a = int(a)
	b = int(b)
	c = int(c)
	n = int(n)
	arr = [a, b, c]
	arr.sort()
	diff1 = arr[2] - arr[0]
	if diff1 > n:
		save.append('NO')
		continue
	diff2 = arr[2] - arr[1]
	if diff2 > n:
		save.append('NO')
		continue
	netdiff = diff1 + diff2
	if netdiff > n:
		save.append('NO')
		continue
	totalnet = n - netdiff
	if totalnet % 3 == 0:
		save.append('YES')
	else:
		save.append('NO')
for i in save:
	print(i, end='\n')


t = int(input())
while t > 0:
	d = list(map(int, input().split()))
	m = max(d[0:-1])
	s = 3 * m - d[0] - d[1] - d[2]
	if d[-1] - s >= 0:
		if (d[-1] - s) % 3 == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')
	t -= 1


t = int(input())
for I in range(t):
	(a, b, c, n) = [int(i) for i in input().split()]
	arr = [a, b, c]
	arr.sort()
	left = 2 * arr[-1] - (arr[1] + arr[0])
	if left > n:
		print('NO')
	else:
		n -= left
		if n % 3 == 0:
			print('YES')
		else:
			print('NO')


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


def maxel(a, b, c):
	max = a
	if max <= b:
		max = b
	if max <= c:
		max = c
	return max
t = int(input())
bo = []
i = 0
while i < t:
	bo.append('NO')
	i += 1
i = 0
while i < t:
	(a, b, c, n) = input().split()
	a = int(a)
	b = int(b)
	c = int(c)
	n = int(n)
	sum = 0
	m = max(a, b, c)
	sum += m - a
	sum += m - b
	sum += m - c
	if sum <= n:
		n -= sum
		if n % 3 == 0:
			bo[i] = 'YES'
	i += 1
for q in bo:
	print(q)


a = int(input())
for x in range(a):
	b = list(map(int, input().split()))
	p = sorted(b[0:3])
	if p[2] - p[0] + (p[2] - p[1]) <= b[3] and sum(b) % 3 == 0:
		print('YES')
	else:
		print('NO')


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


t = int(input())
for i in range(t):
	a = [int(i) for i in input().split()]
	n = a[3]
	a.pop(3)
	a.sort()
	n -= a[2] - a[0] + a[2] - a[1]
	if n >= 0 and n % 3 == 0:
		print('YES')
	else:
		print('NO')


test = int(input())
for times in range(test):
	coins = list(map(int, input().split()))
	dis = coins[-1]
	f = coins[0]
	s = coins[1]
	t = coins[2]
	maxi = max(f, s, t)
	fark = 3 * maxi - f - s - t
	if (dis - fark) % 3 == 0 and dis - fark >= 0:
		print('YES')
	else:
		print('NO')


t = int(input())
h = []
g = 0
m = 0
for i in range(t):
	a = list(map(int, input().split()))
	h.append(a)
for i in range(t):
	m = max(h[i][:3])
	if sum(h[i]) % 3 != 0:
		print('NO')
	elif m > sum(h[i]) // 3:
		print('NO')
	else:
		print('YES')


def canShare(acutal_coins, n):
	higher = max(actual_coins)
	for i in range(len(actual_coins)):
		if actual_coins[i] != higher:
			left = abs(higher - actual_coins[i])
			if n < left:
				return False
			n -= left
			actual_coins[i] += left
	if actual_coins[0] == actual_coins[1] and actual_coins[1] == actual_coins[2] and (n == 0 or n % 3 == 0):
		return True
	return False
t = int(input())
for i in range(t):
	(a, b, c, n) = map(int, input().split())
	actual_coins = [a, b, c]
	can_share = canShare(actual_coins, n)
	result = 'YES' if can_share else 'NO'
	print(result)


for _ in range(int(input())):
	l = list(map(int, input().split()))
	d = l[3]
	l.remove(d)
	m = max(l)
	s = m - l[0] + (m - l[1]) + (m - l[2])
	if s > d:
		print('NO')
		continue
	a = d - s
	if a % 3 == 0:
		print('YES')
	else:
		print('NO')


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


m = int(input())
for i in range(m):
	(a, b, c, n) = map(int, input().split())
	max_m = max(a, b, c)
	min_m_for_parity = max_m * 3 - a - b - c
	if (n - min_m_for_parity) % 3 == 0 and min_m_for_parity <= n:
		print('YES')
	else:
		print('NO')


def sum(a, b, c):
	s = 0
	x = [a, b, c]
	k = max(a, b, c)
	for i in range(len(x)):
		s = s + k - x[i]
	return s
n = int(input())
z = []
for i in range(n):
	(a, b, c, d) = map(int, input().split())
	if sum(a, b, c) > d:
		z.append('NO')
	else:
		d -= sum(a, b, c)
		if d % 3 == 0:
			z.append('YES')
		else:
			z.append('NO')
for i in z:
	print(i)


for _ in range(int(input())):
	(a, b, c, s) = map(int, input().split())
	se = a + b + c + s
	maxi = max(a, b, c)
	if se >= 3 * maxi and se % 3 == 0:
		print('YES')
	else:
		print('NO')


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


N = int(input())
for i in range(0, N):
	(a, b, c, n) = map(int, input().split())
	m = max(max(a, b), c)
	r = 0
	r += abs(m - a)
	r += abs(m - b)
	r += abs(m - c)
	s = a + b + c + n
	if a > s // 3 or b > s // 3 or c > s // 3:
		print('No')
		continue
	if (n - r) % 3 == 0:
		print('YES')
	else:
		print('NO')


from math import *
t = int(input())
for _ in range(t):
	(a, b, c, n) = input().split()
	a = int(a)
	b = int(b)
	c = int(c)
	n = int(n)
	qmin = max(a, b, c)
	val = abs(qmin - a) + abs(qmin - b) + abs(qmin - c)
	finVal = n - val
	if finVal % 3 == 0 and finVal >= 0:
		print('Yes')
	else:
		print('No')


n = int(input())
for x in range(n):
	(a, b, c, n) = list(map(int, input().split()))
	maxx = max(a, b, c)
	if a == maxx:
		pass
	else:
		n -= maxx - a
	if b == maxx:
		pass
	else:
		n -= maxx - b
	if c != maxx:
		n -= maxx - c
	if n > 0 and n % 3 == 0:
		print('YES')
	elif n < 0:
		print('NO')
	elif n == 0:
		print('YES')
	else:
		print('NO')


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

def check(string, sub_str):
	if string.find(sub_str) == -1:
		return False
	else:
		return True
mm = 1000000007

def solve():
	t = nu()
	for tt in range(t):
		(a, b, c, n) = num()
		x = [a, b, c]
		x.sort()
		cc = 0
		pp = x[2] * 2 - x[1] - x[0]
		n -= pp
		if n < 0:
			print('No')
		elif n % 3 == 0:
			print('Yes')
		else:
			print('No')
solve()


def solve():
	(a, b, c, n) = map(int, input().split())
	arr = [a, b, c]
	m = max(arr)
	arrindex = arr.index(m)
	arr.remove(m)
	for x in range(2):
		n -= m - arr[x]
		if n < 0:
			print('NO')
			return
	if n % 3 == 0:
		print('YES')
	else:
		print('NO')
t = int(input())
for x in range(t):
	solve()


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


x = int(input())
for i in range(x):
	s = 0
	p = 0
	q = 0
	r = 0
	e = 0
	(a, b, c, n) = map(int, input().split())
	p = max(a, b, c) - a
	q = max(a, b, c) - b
	r = max(a, b, c) - c
	s = p + q + r
	e = n - s
	if e >= 0:
		if e % 3 == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


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


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush, nlargest, nsmallest, _heapify_max, _heapreplace_max
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque, Counter as c
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from fractions import Fraction
mod = pow(10, 9) + 7
mod2 = 998244353

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

def out(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def l():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
for _ in range(int(data())):
	arr = l()
	n = arr[-1]
	arr.pop()
	arr.sort()
	diff = 2 * arr[2] - (arr[1] + arr[0])
	n -= diff
	if n >= 0 and n % 3 == 0:
		out('YES')
		continue
	out('NO')


t = int(input())
out = []
for i in range(0, t):
	inp = list(map(int, input().split()))
	total = inp.pop(3)
	inp.sort()
	diff = 2 * inp[2] - inp[1] - inp[0]
	total -= diff
	if total < 0 or total % 3 != 0:
		out.append('NO')
	else:
		out.append('YES')
for i in range(0, t):
	print(out[i])


for case in range(int(input())):
	(a, b, c, n) = [int(x) for x in input().split()]
	total = a + b + c + n
	avg = total / 3
	if total % 3 == 0 and a <= avg and (b <= avg) and (c <= avg):
		print('YES')
	else:
		print('NO')


def calc(a: int, b: int, c: int, n: int):
	arr: list = sorted([a, b, c])
	diffA: int = arr[2] - arr[0]
	diffB: int = arr[2] - arr[1]
	diffTotal: int = diffA + diffB
	n -= diffTotal
	if n % 3 == 0 and 0 <= n:
		return 'YES'
	else:
		return 'NO'

def main():
	for _ in range(int(input())):
		(a, b, c, n) = map(int, input().split())
		print(calc(a, b, c, n))
main()


for u in range(int(input())):
	(a, b, c, n) = map(int, input().split())
	s = a + b + c + n
	if s % 3 == 0:
		ka = s / 3
		if a <= ka and b <= ka and (c <= ka):
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


def func(abcn):
	abcn = list(map(int, abcn.split()))
	abc = abcn[:3]
	if sum(abcn) % 3 == 0:
		if abcn[-1] >= sum([max(abc) - i for i in abc]):
			return 'YES'
	return 'NO'

def main():
	t = int(input())
	output = list(map(func, [input() for i in range(t)]))
	for i in output:
		print(i)
main()


import math
MOD = 10 ** 9 + 7
for _ in range(int(input())):
	f = False
	(a, b, c, n) = map(int, input().split())
	s = a + b + c + n
	if s % 3 == 0 and max(a, b, c) <= s // 3:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(a, b, c, n) = [int(j) for j in input().split()]
	m = max(a, b, c)
	p = 3 * m - (a + b + c)
	if n >= p:
		if (n - p) % 3 == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


t = int(input())
l2 = []
for i in range(t):
	(a, b, c, n) = map(int, input().split())
	if (a + b + c + n) % 3 == 0:
		if max(a, b, c) <= int((a + b + c + n) / 3):
			l2.append('YES')
		else:
			l2.append('NO')
	else:
		l2.append('NO')
for i in range(t):
	print(l2[i])


for _ in [0] * int(input()):
	(*a, n) = map(int, input().split())
	(a, b, c) = sorted(a)
	d = n - 2 * c + a + b
	print('YNEOS'[d | -(d % 3) < 0::2])


t = int(input())
for _ in range(t):
	(a, b, c, n) = map(int, input().strip().split(' '))
	res1 = a + c + n - 2 * b
	res2 = a + b + n - 2 * c
	res3 = b + c + n - 2 * a
	if res1 >= 0 and res2 >= 0 and (res3 >= 0) and (res1 % 3 == 0) and (res2 % 3 == 0) and (res3 % 3 == 0):
		print('YES')
	else:
		print('NO')


n = int(input())
s = []
for i in range(n):
	(a, b, c, t) = map(int, input().split())
	d = max(a, b)
	first = max(d, c)
	f = min(a, b)
	last = min(f, c)
	l = [a, b, c]
	l.remove(first)
	l.remove(last)
	mid = l[0]
	x = first - mid
	y = first - last
	mid = mid + x
	t = t - x
	last = last + y
	t = t - y
	if t % 3 == 0 and t >= 0:
		s.append('YES')
	else:
		s.append('NO')
for i in range(len(s)):
	print(s[i])


from sys import stdin
t = int(stdin.readline().strip())
for i in range(t):
	(a, b, c, n) = map(int, stdin.readline().split())
	if a < b:
		t = abs(b - a)
		a += t
		n -= t
	else:
		t = abs(b - a)
		b += t
		n -= t
	if a < c:
		t = abs(c - a)
		a += t
		b += t
		n = n - 2 * t
	else:
		t = abs(a - c)
		c += t
		n = n - t
	if n < 0 or n % 3 != 0:
		print('NO')
	else:
		print('YES')


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

def ai():
	a = list(map(int, input().split()))
	return a

def mi():
	a = map(int, input().split())
	return a
for _ in range(ii()):
	(a, b, c, n) = mi()
	need = max(a, b, c) * 3
	ac_sum = a + b + c
	diff = need - ac_sum
	left_coin = n - diff
	if diff <= n and left_coin // 3 == left_coin / 3:
		print('Yes')
	else:
		print('No')


num_test = int(input())
for test in range(num_test):
	test_input = input().split()
	a = int(test_input[0])
	b = int(test_input[1])
	c = int(test_input[2])
	n = int(test_input[3])
	all_coin = a + b + c + n
	if all_coin % 3 != 0:
		print('NO')
	else:
		divided = int(all_coin / 3)
		if divided < a or divided < b or divided < c:
			print('NO')
		else:
			print('YES')


t = int(input())
for e in range(t):
	(a, b, c, n) = input().split()
	a = int(a)
	b = int(b)
	c = int(c)
	n = int(n)
	l = [a, b, c]
	x = max(l)
	x1 = x - a
	x2 = x - b
	x3 = x - c
	a = x - a + a
	b = x - b + b
	c = x - c + c
	n = n - x1 - x2 - x3
	if n % 3 == 0 and n > 0:
		print('YES')
	elif a == b and a == c and (n == 0):
		print('YES')
	else:
		print('NO')


t = int(input())
while t > 0:
	sum = 0
	max = 0
	maxindex = -1
	i = 0
	coins = input().split(' ')
	coins = [int(i) for i in coins]
	while i < len(coins) - 1:
		sum += coins[i]
		if coins[i] > max:
			max = coins[i]
			maxindex = i
		i += 1
	n = coins.pop()
	sum += n
	minVal = max - coins[maxindex - 1] + (max - coins[maxindex - 2])
	if round(sum % 3) == 0 and sum > 0:
		if n >= minVal:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')
	t -= 1


t = int(input())
while t > 0:
	(a, b, c, n) = map(int, input().split())
	a = sorted([a, b, c], reverse=True)
	k = abs(a[0] - a[1]) + abs(a[0] - a[2])
	if abs(a[0] - a[1]) + abs(a[0] - a[2]) <= n:
		if (n - k) % 3 == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')
	t -= 1


tc = int(input())
for i in range(tc):
	(a, b, c, n) = map(int, input().split())
	maxi = max(a, b, c)
	a1 = abs(maxi - a)
	a2 = abs(maxi - b)
	a3 = abs(maxi - c)
	if a1 + a2 + a3 > n:
		print('NO')
	else:
		n -= a1 + a2 + a3
		if n % 3 == 0:
			print('YES')
		else:
			print('NO')


x = int(input()) + 1
for i in range(1, x, 1):
	(a, b, c, d) = input().split()
	a = int(a)
	b = int(b)
	c = int(c)
	d = int(d)
	import math
	mx = max(a, b, c)
	n = 3 * mx - a - b - c
	sum = a + b + c + d
	m = sum % 3
	if m != 0 or n > d:
		print('NO')
	else:
		print('YES')


n = int(input())

def greatest(a, b, c):
	great = a
	if b > great:
		great = b
	if c > great:
		great = c
	return great
for i in range(n):
	(a, b, c, n) = [int(s) for s in input().split(' ')]
	greater = greatest(a, b, c)
	temp = greater - a + (greater - b) + (greater - c)
	if n - temp >= 0 and (n - temp) % 3 == 0:
		print('YES')
	else:
		print('NO')


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


t = int(input())
if 1 <= t <= 10 ** 4:
	for i in range(t):
		(a, b, c, n) = input().split()
		a = int(a)
		b = int(b)
		c = int(c)
		n = int(n)
		if 1 <= a <= 10 ** 8 and 1 <= b <= 10 ** 8 and (1 <= c <= 10 ** 8) and (1 <= n <= 10 ** 8):
			if a == b == c:
				if n % 3 == 0:
					print('yes')
				else:
					print('no')
			elif a > b and a > c:
				d = a - b
				e = a - c
				f = n - d - e
				if f >= 0 and f % 3 == 0:
					print('yes')
				else:
					print('no')
			elif b > a and b > c:
				g = b - a
				h = b - c
				i = n - g - h
				if i >= 0 and i % 3 == 0:
					print('yes')
				else:
					print('no')
			elif c > a and c > b:
				j = c - a
				k = c - b
				l = n - j - k
				if l >= 0 and l % 3 == 0:
					print('yes')
				else:
					print('no')
			elif a == b > c:
				d = a - c
				f = n - d
				if f >= 0 and f % 3 == 0:
					print('yes')
				else:
					print('no')
			elif b == c > a:
				d = b - a
				f = n - d
				if f >= 0 and f % 3 == 0:
					print('yes')
				else:
					print('no')
			elif a == c > b:
				d = a - b
				f = n - d
				if f >= 0 and f % 3 == 0:
					print('yes')
				else:
					print('no')


def middle(a, b, c):
	if a > b:
		if b > c:
			return b
		elif a > c:
			return c
		else:
			return a
	elif a > c:
		return a
	elif b > c:
		return c
	else:
		return b
for i in range(int(input())):
	(x, y, z, t) = map(int, input().split())
	t = t - (max(x, y, z) - min(x, y, z) + (max(x, y, z) - middle(x, y, z)))
	if t >= 0 and t % 3 == 0:
		print('YES')
	else:
		print('NO')


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


for p in range(int(input())):
	l = list(map(int, input().split()))
	n = l[3]
	l.remove(n)
	c = 0
	for i in l:
		c += max(l) - i
	if c <= n:
		n -= c
		if n % 3 == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


import statistics
n = int(input())
lista = []
for e in range(n):
	nums = input().split()
	count = 0
	maximo = max(int(nums[0]), int(nums[1]), int(nums[2]))
	minimo = min(int(nums[0]), int(nums[1]), int(nums[2]))
	medio = statistics.median([int(nums[0]), int(nums[1]), int(nums[2])])
	if int(nums[3]) - (maximo - minimo + (maximo - medio)) >= 0:
		if (int(nums[3]) - (maximo - minimo + (maximo - medio))) % 3 == 0:
			lista.append('YES')
		else:
			lista.append('NO')
	else:
		lista.append('NO')
for i in range(n):
	print(lista[i])


t = int(input())
ans = []
for i in range(t):
	s = input().split()
	a = int(s[0])
	b = int(s[1])
	c = int(s[2])
	n = int(s[3])
	arr = [a, b, c]
	arr.sort()
	d = 2 * arr[2] - arr[0] - arr[1]
	if d > n or (a + b + c + n) % 3 != 0:
		ans.append('no')
	else:
		ans.append('yes')
for aa in ans:
	print(aa)


for t in range(int(input())):
	a = list(map(int, input().split()))
	print('YES' if sum(a) % 3 == 0 and 3 * max(a[:3]) - sum(a[:3]) <= a[3] else 'NO')


t = int(input())
for _ in range(t):
	b = []
	for a in input().split():
		b.append(int(a))
	m = 0
	m1 = 0
	m2 = 0
	for i in range(3):
		if b[i] > m:
			m2 = m1
			m1 = m
			m = b[i]
		elif b[i] > m1:
			m2 = m1
			m1 = b[i]
		else:
			m2 = b[i]
	b[3] -= m - m1 + m - m2
	if b[3] % 3 == 0 and b[3] >= 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(a, b, c, n) = map(int, input().split())
	lst = []
	lst.append(a)
	lst.append(b)
	lst.append(c)
	lst.sort()
	s = lst[2] - lst[0] + (lst[2] - lst[1])
	if n >= s:
		n = n - s
		if n % 3 == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(a, b, c, n) = map(int, input().split())
	s = []
	s.extend([a, b, c])
	s.sort()
	q = s[-1] - s[-2] + (s[-1] - s[-3])
	if q > n:
		print('No')
	elif (n - q) % 3 == 0:
		print('Yes')
	else:
		print('No')


t = int(input())
for i in range(t):
	(a, b, c, n) = map(int, input().split())
	f = [a, b, c]
	f_max = max(f)
	f.remove(f_max)
	if n >= f_max - max(f) + (f_max - min(f)):
		if (a + b + c + n) % 3 == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


import sys
number_cases = int(input())
for _ in range(number_cases):
	lista = list(map(int, input().strip().split()))
	total = lista[3]
	del lista[3]
	maximum = max(lista)
	sirve = True
	for i in lista:
		if i != maximum:
			difference = maximum - i
			total -= difference
			i += difference
	if total < 0:
		print('NO')
	elif total == 0:
		print('YES')
	elif total > 0 and total % 3 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(a, b, c, n) = map(int, input().split())
	l = [a, b, c]
	m = max(l)
	for j in range(len(l)):
		if n == 0:
			break
		if l[j] < m:
			ans = m - l[j]
			if n >= ans:
				l[j] += ans
				n -= ans
			else:
				l[j] += n
				n -= n
	if l[0] == l[1] and l[0] == l[2] and (n % 3 == 0):
		print('YES')
	else:
		print('NO')


def find(a, b, c, n):
	if (a + b + c + n) % 3 == 0:
		m = (a + b + c + n) // 3
		if m >= max(a, b, c):
			return True
	return False
t = int(input())
for test in range(t):
	(a, b, c, n) = [int(item) for item in input().split()]
	if find(a, b, c, n):
		print('YES')
	else:
		print('NO')


po = int(input())
for _ in range(po):
	(a, b, c, d) = map(int, input().split())
	x = a + b + c + d
	print(['NO', 'YES'][x % 3 == 0 and a <= x // 3 and (b <= x // 3) and (c <= x // 3)])


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


for _ in range(int(input())):
	(a, b, c, n) = map(int, input().split())
	x = max(a, b, c)
	p = x - a
	q = x - b
	r = x - c
	y = p + q + r
	if n - y < 0:
		print('NO')
	elif (n - y) % 3 == 0:
		print('YES')
	else:
		print('NO')


tstc = int(input())
l = []
for i in range(tstc):
	(a, b, c, p) = input().split()
	(a, b, c, p) = (int(a), int(b), int(c), int(p))
	s = a + b + c + p
	if s % 3 == 0:
		s = s / 3
		if s >= max(a, max(b, c)):
			l.append('YES')
		else:
			l.append('NO')
	else:
		l.append('NO')
for i in l:
	print(i)


import sys
import math
input = sys.stdin.readline

def inp():
	return int(input())

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

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
t = inp()
for i in range(t):
	xxx = inlt()
	n = xxx.pop(3)
	xxx.sort()
	x = xxx[0] + xxx[1] + xxx[2]
	d1 = xxx[2] - xxx[0]
	d2 = xxx[2] - xxx[1]
	d = d1 + d2
	if d > n:
		print('NO')
	else:
		n = n - d
		if n % 3 == 0:
			print('YES')
		else:
			print('NO')


def solution(a, b, c, n):
	v = sorted((a, b, c))
	dif = v[2] - v[1] + v[2] - v[0]
	size = v[2] + v[1] + v[0] + n
	if dif <= n and size % 3 == 0:
		return 'YES'
	return 'NO'

def read():
	cnt = int(input())
	for _ in range(cnt):
		(a, b, c, n) = tuple(map(int, input().split()))
		print(solution(a, b, c, n))
read()


n = input()
n = int(n)
for i in range(n):
	(a, b, c, d) = input().split()
	a = int(a)
	b = int(b)
	c = int(c)
	d = int(d)
	counter = 0
	diff = 0
	if a > b:
		diff = a - b
		b += diff
		counter += diff
	elif b > a:
		diff = b - a
		a += diff
		counter += diff
	if a == b:
		if b > c:
			diff = b - c
			c += diff
			counter += diff
		elif c > b:
			diff = c - b
			b += diff
			counter += diff
			a += diff
			counter += diff
	if counter == d:
		print('YES')
	elif counter < d:
		diff = d - counter
		if diff % 3 == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


n = int(input())
while n != 0:
	arr = list(map(int, input().split()))
	summ = 0
	for i in range(4):
		summ += arr[i]
	if summ % 3 != 0:
		print('NO')
	else:
		summ = summ / 3
		if summ < arr[0] or summ < arr[1] or summ < arr[2]:
			print('NO')
		else:
			print('YES')
	n -= 1


t = int(input())
for _ in range(t):
	(a, b, c, n) = map(int, input().split())
	(a, b, c) = sorted([a, b, c])
	need = 2 * c - b - a
	print('YES' if n >= need and n % 3 == need % 3 else 'NO')


for _ in range(int(input())):
	(a, b, c, n) = map(int, input().split())
	p = max(a, b, c)
	temp1 = abs(a - p)
	temp2 = abs(b - p)
	temp3 = abs(c - p)
	temp4 = temp1 + temp2 + temp3
	n -= temp4
	if n % 3 == 0 and n >= 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(a, b, c, n) = list(map(int, input().strip().split(' ')))
	arr = [a, b, c]
	arr = sorted(arr)
	m = 3 * arr[2] - sum(arr)
	s = sum(arr) + n
	if n < m:
		print('NO')
	elif s % 3 == 0:
		print('YES')
	else:
		print('NO')


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


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


t = int(input())
for i in range(t):
	(a, b, c, n) = map(int, input().split())
	Max = max(a, b, c)
	answer = 0
	answer += abs(Max - a)
	answer += abs(Max - b)
	answer += abs(Max - c)
	if n - answer < 0 or (n - answer) % 3 != 0:
		print('NO')
	else:
		print('YES')


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


t = int(input())
for i in range(t):
	l = [int(i) for i in input().split()]
	n = l.pop()
	c = n - (max(l) * 3 - sum(l))
	if c >= 0 and c % 3 == 0:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	l = list(map(int, input().split()))
	n = l[-1]
	l = l[:-1]
	m = max(l)
	sum = 0
	for j in range(len(l)):
		sum += m - l[j]
	if n >= sum and (n - sum) % 3 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	l = list(map(int, input().split()))
	a = l[0]
	b = l[1]
	c = l[2]
	n = l[3]
	bb = max(a, b, c)
	v1 = bb - a
	v2 = bb - b
	v3 = bb - c
	nn = n - (v1 + v2 + v3)
	if nn >= 0 and nn % 3 == 0:
		print('YES')
	else:
		print('NO')


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


def mid(arr: list) -> int:
	return sorted(arr)[1]
t = int(input())
cases = [list(map(int, input().split())) for _ in range(t)]
for case in cases:
	min_eq = sum((max(case[:-1]) - c for c in case[:-1]))
	if case[3] >= min_eq and (case[3] - min_eq) % 3 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
res = []
for _ in range(t):
	(a, b, c, n) = map(int, input().split())
	m = max(a, b, c)
	r = n - (3 * m - a - b - c)
	if r % 3 == 0 and r >= 0:
		res.append('YES')
	else:
		res.append('NO')
for el in res:
	print(el)


for _ in range(int(input())):
	(a, b, c, n) = map(int, input().split())
	e = max(a, b, c)
	z = e - a + (e - b) + (e - c)
	n = n - z
	if n >= 3 and n % 3 == 0:
		print('YES')
	elif n == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
while t:
	l = list(map(int, input().split()))
	if l[0] > l[1]:
		if l[0] > l[2]:
			max1 = 0
		else:
			max1 = 2
	elif l[1] > l[2]:
		max1 = 1
	else:
		max1 = 2
	i = max1
	j = 0
	sum1 = abs(l[i] - l[j]) + abs(l[i] - l[j + 1]) + abs(l[i] - l[j + 2])
	if l[3] - sum1 >= 0 and (l[3] - sum1) % 3 == 0:
		print('YES')
	else:
		print('NO')
	t = t - 1


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


def solve(a, b, c, n):
	ar = [a, b, c]
	maxi = max(ar)
	diff = 0
	for i in range(len(ar)):
		diff += maxi - ar[i]
	if diff <= n and (n - diff) % 3 == 0:
		print('YES')
	else:
		print('NO')
t = int(input())
for _ in range(t):
	(a, b, c, n) = map(int, input().split())
	solve(a, b, c, n)


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


import sys
input = sys.stdin.readline
n = int(input())
for i in range(n):
	(a, b, c, n) = map(int, input().split())
	sum_ = a + b + c
	total = sum_ + n
	if total % 3 == 0:
		quot = total / 3
		if a <= quot and b <= quot and (c <= quot):
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(a, b, c, n) = map(int, input().split())
	ma = max(a, b, c)
	exa = ma - a
	exb = ma - b
	exc = ma - c
	nleft = n - exa - exb - exc
	if nleft >= 0 and nleft % 3 == 0:
		print('YES')
	else:
		print('NO')


def main():
	t = int(input())
	for __ in range(t):
		s = list(map(int, input().split()))
		if sum(s) % 3:
			print('NO')
		else:
			k = sum(s) // 3
			if k >= s[0] and k >= s[1] and (k >= s[2]):
				print('YES')
			else:
				print('NO')
main()


a = int(input())
while a != 0:
	(b, c, d, e) = input().split()
	(b, c, d, e) = [int(b), int(c), int(d), int(e)]
	m = max(b, c, d)
	if m == b:
		s = b - c
		e = e - s
		if e >= 0:
			c = c + s
		s = b - d
		e = e - s
		if e >= 0:
			d = d + s
	if m == c:
		s = c - b
		e = e - s
		if e >= 0:
			b = b + s
		s = c - d
		e = e - s
		if e >= 0:
			d = d + s
	if m == d:
		s = d - c
		e = e - s
		if e >= 0:
			c = c + s
		s = d - b
		e = e - s
		if e >= 0:
			b = b + s
	if b == c == d and e == 0:
		print('YES')
	elif b == c == d and e % 3 == 0:
		print('YES')
	else:
		print('NO')
	a = a - 1


from sys import stdin
from collections import defaultdict
T = int(stdin.readline())
for _ in range(T):
	(a, b, c, n) = list(map(int, stdin.readline().rstrip().split()))
	t = a + b + c + n
	p = t / 3.0
	if p == int(p):
		if max(a, b, c, p) == p:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


def solve():
	(a, b, c, n) = map(int, input().split())
	s = a + b + c + n
	if s % 3 != 0 or max(a, b, c) > s // 3:
		return 'NO'
	return 'YES'

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


import sys
inputs = []
for line in sys.stdin:
	inputs.append(line.rstrip().split())
for i in inputs[1:]:
	i = list(map(float, i))
	if sum(i) % 3 == 0 and sum(i) >= max(i[:3]) * 3:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	coin = [int(i) for i in input().split()]
	n = coin.pop()
	coin.sort()
	count = 0
	for i in range(2):
		count += coin[len(coin) - 1] - coin[i]
	n = n - count
	if n >= 0:
		if n % 3 == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


t = int(input())
for i in range(0, t):
	L = list(map(int, input().split()))
	x = L[0] + L[1] + L[2] + L[3]
	if x % 3 != 0:
		print('NO')
	elif x - 3 * L[0] < 0 or x - 3 * L[1] < 0 or x - 3 * L[2] < 0:
		print('NO')
	else:
		print('YES')


def coins_problem():
	test_cases = input()
	coins = []
	for i in range(int(test_cases)):
		coins.append(input().split())
	for i in range(len(coins)):
		go = True
		while int(coins[i][-1]) > 0:
			if int(coins[i][0]) != int(coins[i][1]) and int(coins[i][-1]) >= abs(int(coins[i][0]) - int(coins[i][1])):
				coins[i][-1] = int(coins[i][-1]) - abs(int(coins[i][0]) - int(coins[i][1]))
				if int(coins[i][0]) < int(coins[i][1]):
					coins[i][0] = int(coins[i][0]) + abs(int(coins[i][0]) - int(coins[i][1]))
				else:
					coins[i][1] = int(coins[i][1]) + abs(int(coins[i][0]) - int(coins[i][1]))
			elif int(coins[i][0]) != int(coins[i][2]) and int(coins[i][-1]) >= abs(int(coins[i][0]) - int(coins[i][2])):
				coins[i][-1] = int(coins[i][-1]) - abs(int(coins[i][0]) - int(coins[i][2]))
				if int(coins[i][0]) < int(coins[i][2]):
					coins[i][0] = int(coins[i][0]) + abs(int(coins[i][0]) - int(coins[i][2]))
				else:
					coins[i][2] = int(coins[i][2]) + abs(int(coins[i][0]) - int(coins[i][2]))
			elif int(coins[i][0]) == int(coins[i][1]) and int(coins[i][0]) == int(coins[i][2]):
				if int(coins[i][-1]) > 2:
					if int(coins[i][-1]) % 3 != 0:
						print('NO')
						break
					else:
						print('YES')
						break
				elif int(coins[i][-1]) == 0:
					print('YES')
					break
				else:
					print('NO')
					break
			else:
				print('NO')
				go = False
				break
		if int(coins[i][0]) == int(coins[i][1]) and int(coins[i][0]) == int(coins[i][2]) and int(coins[i][3] == 0):
			print('YES')
		elif (int(coins[i][0]) != int(coins[i][1]) or int(coins[i][0]) != int(coins[i][2])) and go:
			print('NO')
	return
coins_problem()


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(a, b, c, n) = [int(i) for i in input().split()]
	x = max(a, b, c) - a
	y = max(a, b, c) - b
	z = max(a, b, c) - c
	n -= x + y + z
	print('YES' if n >= 0 and (not n % 3) else 'NO')


t = int(input())
for _ in range(t):
	z = [int(x) for x in input().split(' ')]
	a = z[0]
	b = z[1]
	c = z[2]
	n = z[3]
	m = a + b + c + n
	if m % 3 != 0:
		print('NO')
	else:
		m = m // 3
		if a <= m and b <= m and (c <= m):
			print('YES')
		else:
			print('NO')


N = int(input())
for _ in range(N):
	inp = input()
	(a, b, c, n) = map(lambda x: int(x), inp.split())
	_max = max(a, b, c)
	n -= _max - a
	n -= _max - b
	n -= _max - c
	if n < 0:
		print('NO')
	elif n == 0 or n % 3 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
otvety = []
for i in range(0, t):
	s = input()
	temp = s.split()
	a = int(temp[0])
	b = int(temp[1])
	c = int(temp[2])
	n = int(temp[3])
	ans = 'YES'
	summa = a + b + c + n
	if summa % 3 != 0:
		ans = 'NO'
	else:
		x = summa / 3
		if a > x or b > x or c > x:
			ans = 'NO'
	otvety.append(ans)
for element in otvety:
	print(element)


for t in range(int(input())):
	(a, b, c, n) = map(int, input().split())
	maxi = max(a, b, c)
	a1 = maxi - a
	a2 = maxi - b
	a3 = maxi - c
	n -= a1 + a2 + a3
	if n >= 0 and n % 3 == 0:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(a, b, c, n) = map(int, input().split(' '))
	new_abc = sorted([a, b, c])
	rem_n = n - (new_abc[-1] - new_abc[0]) - (new_abc[-1] - new_abc[1])
	if rem_n >= 0 and rem_n % 3 == 0:
		print('YES')
	else:
		print('NO')


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


num_cases = int(input())

def can_divide(lst, n):
	maximum = max(lst)
	divide_among = maximum - lst[0] + (maximum - lst[1]) + (maximum - lst[2])
	if n - divide_among < 0:
		return False
	return (n - divide_among) % 3 == 0
for _ in range(num_cases):
	coins = [int(i) for i in input().split(' ')]
	if can_divide(coins[:3], coins[-1]):
		print('YES')
	else:
		print('NO')


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


k = int(input())
for kk in range(k):
	abcn = input().split(' ')
	a = int(abcn[0])
	b = int(abcn[1])
	c = int(abcn[2])
	n = int(abcn[3])
	t = max(a, b, c)
	left = round(n - (3 * t - (a + b + c)))
	if left < 0:
		print('NO')
	elif left == 0:
		print('YES')
	elif left % 3 == 0:
		print('YES')
	else:
		print('NO')


a = int(input())
for i in range(a):
	(b, c, d, e) = map(int, input().split())
	if (b + c + d + e) % 3:
		print('NO')
	else:
		f = (b + c + d + e) // 3
		if f == max(f, b, c, d):
			print('YES')
		else:
			print('NO')


t = int(input())
for i in range(t):
	(a, b, c, n) = map(int, input().split())
	maxi = max(a, b, c)
	sum = maxi - a + maxi - b + maxi - c
	if sum <= n:
		if (n - sum) % 3 == 0:
			print('YES')
		else:
			print('No')
	else:
		print('NO')


t = int(input())
while t > 0:
	t = t - 1
	(a, b, c, n) = map(int, input().split())
	l = list()
	l.append(a)
	l.append(b)
	l.append(c)
	l.sort()
	n = n - (2 * l[2] - l[1] - l[0])
	if n < 0 or n % 3 != 0:
		print('NO')
	else:
		print('YES')


from bisect import bisect_left, bisect_right
from typing import List
import collections
import bisect
import itertools
import functools
from fractions import gcd
import heapq
from math import ceil, sqrt, floor
import sys
sys.setrecursionlimit(50000)
import collections
from collections import defaultdict, deque
import collections
import bisect
from collections import defaultdict, deque
import collections
t = int(input())
for _ in range(t):
	(a, b, c, n) = list(map(int, input().split()))
	arr = [a, b, c]
	arr.sort(reverse=True)
	required = abs(arr[0] - arr[1]) + abs(arr[0] - arr[2])
	if required <= n and (n - required) % 3 == 0:
		print('YES')
	else:
		print('NO')


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


for _ in range(int(input())):
	(a, b, c, n) = map(int, input().split())
	lst = [a, b, c]
	m = max(lst)
	lst.remove(m)
	x = m - lst[0]
	y = m - lst[1]
	z = n - x - y
	if z < 0:
		print('NO')
	elif z % 3 == 0:
		print('YES')
	elif z % 3 != 0:
		print('NO')


n = int(input())
arr = []
ans = []
d = []
for i in range(n):
	ans = []
	arr = []
	ans = input().split(' ')
	for j in range(0, len(ans)):
		arr.append(int(ans[j]))
	if arr[0] < arr[1]:
		(arr[0], arr[1]) = (arr[1], arr[0])
	if arr[0] < arr[2]:
		(arr[0], arr[2]) = (arr[2], arr[0])
	s = arr[0] - arr[2] + arr[0] - arr[1]
	s = arr[3] - s
	if s % 3 != 0 or s < 0:
		d.append('NO')
	else:
		d.append('YES')
for a in d:
	print(a)


t = int(input())
result = []
for i in range(t):
	(a, b, c, n) = map(int, input().split())
	arr = [a, b, c]
	arr.sort()
	if arr[2] - arr[1] + (arr[2] - arr[0]) <= n:
		if (n - (arr[2] - arr[1]) - (arr[2] - arr[0])) % 3 == 0:
			result.append('YES')
		else:
			result.append('NO')
	else:
		result.append('NO')
print('\n'.join(result))


t = int(input())
for i in range(t):
	(a, b, c, n) = map(int, input().split())
	p = [a, b, c]
	p.sort()
	max1 = p[2]
	max2 = p[1]
	min1 = p[0]
	if n - (max1 - max2) - (max1 - min1) < 0:
		print('NO')
	else:
		n = n - (max1 - max2)
		n = n - (max1 - min1)
		if n % 3 == 0:
			print('YES')
		elif n % 3 != 0:
			print('NO')


t = int(input())
for _ in range(t):
	l = [int(l) for l in input().split()]
	n = l[-1]
	l1 = []
	for i in range(0, 3):
		l1.append(l[i])
	l1.sort()
	p = l1[2] - l1[1] + l1[2] - l1[0]
	n -= p
	if n < 0 or n % 3 != 0:
		print('NO')
	else:
		print('YES')


import sys
queries = int(sys.stdin.readline())

def doQueries(queries):
	for query in range(queries):
		(a, b, c, n) = map(int, sys.stdin.readline().split())
		coins = [a, b, c]
		coins.sort()
		n = n - (coins[2] - coins[1]) - (coins[2] - coins[0])
		if n >= 0 and n % 3 == 0:
			print('YES')
		else:
			print('NO')
doQueries(queries)


import sys, itertools, math
T = int(sys.stdin.readline())
for _ in range(T):
	(a, b, c, n) = [int(i) for i in sys.stdin.readline().strip().split(' ')]
	total_coins = a + b + c + n
	if total_coins % 3 != 0:
		print('NO')
		continue
	coin_per_person = total_coins // 3
	if max(a, b, c) > coin_per_person:
		print('NO')
		continue
	n -= coin_per_person - a
	n -= coin_per_person - b
	n -= coin_per_person - c
	if n == 0:
		print('YES')
	else:
		print('NO')


def f(a, b, c, n):
	if a >= b and a >= c:
		diff = n - (a - b + a - c)
	elif b >= a and b >= c:
		diff = n - (b - a + b - c)
	elif c >= a and c >= b:
		diff = n - (c - a + c - b)
	else:
		raise ValueError
	return 'YES' if diff >= 0 and diff % 3 == 0 else 'NO'
t = int(input())
for _ in range(t):
	print(f(*list(map(int, input().split()))))


def cole(k):
	(a, b, c, n) = list(map(int, k.split()))
	l = [a, b, c]
	l.sort()
	n -= l[2] - l[1]
	n -= l[2] - l[0]
	if n == 0:
		return 'YES'
	elif n % 3 == 0 and n > 0:
		return 'YES'
	else:
		return 'NO'
t = int(input())
for c in range(t):
	print(cole(input()))


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()

def sieve(x):
	a = [True] * (x + 1)
	sq = floor(sqrt(x))
	for i in range(3, sq + 1, 2):
		if a[i]:
			for j in range(i * i, x + 1, i):
				a[j] = False
	if x > 1:
		p = [2]
	else:
		p = []
	for i in range(3, x + 1, 2):
		if a[i]:
			p.append(i)
	return p
for _ in range(ii()):
	x = li()
	n = x[3]
	a = x[:3]
	a.sort()
	n -= a[2] - a[0]
	n -= a[2] - a[1]
	print('YES' if n >= 0 and (not n % 3) else 'NO')


def f(L):
	a = L[0]
	b = L[1]
	c = L[2]
	d = L[3]
	if a == b and b == c:
		if d % 3 == 0:
			return 'YES'
		else:
			return 'NO'
	else:
		if a >= b and a >= c:
			counter = a - b + (a - c)
		elif b >= a and b >= c:
			counter = b - a + (b - c)
		else:
			counter = c - a + (c - b)
		d = d - counter
		if d < 0 or d % 3 != 0:
			return 'NO'
		if d == 0 or d % 3 == 0:
			return 'YES'
n = int(input(''))
L2 = []
for i in range(n):
	L = [x for x in input('').split()]
	for j in range(len(L)):
		L[j] = int(L[j])
	L2.append(L)
for i in range(len(L2)):
	print(f(L2[i]))


N_SETS = int(input())
for i in range(N_SETS):
	(a, b, c, n) = [int(x) for x in input().split()]
	M = max(a, b, c)
	eq = 3 * M - a - b - c
	if (n - eq) % 3 == 0 and n - eq >= 0:
		print('YES')
	else:
		print('NO')


def f(m, x, y, t):
	if m - x + (m - y) == t:
		return True
	elif m - x + (m - y) < t:
		if (t - (m - x) - (m - y)) % 3 == 0:
			return True
		return False
	return False
q = int(input())
for _ in range(q):
	(a, b, c, n) = map(int, input().split())
	ma = max(a, b, c)
	ok = False
	if ma == a:
		ok = f(a, b, c, n)
	elif ma == b:
		ok = f(b, a, c, n)
	elif ma == c:
		ok = f(c, a, b, n)
	if ok:
		print('YES')
	else:
		print('NO')


from sys import stdin, stdout

def solve():
	(a, b, c, n) = [int(i) for i in stdin.readline().split()]
	k = max(a, b, c)
	for i in (a, b, c):
		n = n - (k - i)
	if n < 0:
		return 'NO'
	return 'YES' if n % 3 == 0 else 'NO'
t = int(input())
for i in range(t):
	print(solve())


t = int(input())
for qwe in range(t):
	(a, b, c, n) = map(int, input().split())
	q = sorted([a, b, c])
	if q[2] - q[1] + q[2] - q[0] <= n:
		n -= q[2] - q[1] + q[2] - q[0]
		if n % 3 == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


t = int(input())
for f in range(t):
	(a, b, c, n) = map(int, input().split())
	maxi = max(a, b, c)
	if maxi == a:
		k = maxi - b + maxi - c
	elif maxi == b:
		k = maxi - a + maxi - c
	else:
		k = maxi - a + maxi - b
	if k <= n and (n - k) % 3 == 0:
		print('YES')
	else:
		print('NO')


def mi():
	return map(int, input().split())
for _ in range(int(input())):
	(a, b, c, n) = mi()
	(a, b, c) = sorted([a, b, c])
	if c - a + (c - b) <= n:
		taken = c - a + c - b
		if (n - taken) % 3 == 0:
			print('YES')
			continue
	print('NO')


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

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

def S():
	return str(input())

def L():
	return list(R())
from collections import Counter
import math
import sys
for _ in range(I()):
	(a, b, c, n) = R()
	if (n + a + b + c) % 3 != 0:
		print('NO')
		continue
	x = (n + a + b + c) // 3
	if x - a < 0 or x - a > n:
		print('NO')
		continue
	if x - b < 0 or x - b > n:
		print('NO')
		continue
	if x - c < 0 or x - c > n:
		print('NO')
		continue
	print('YES')


t = int(input())
for i in range(t):
	(a, b, c, n) = map(int, input().split())
	if b > a:
		(a, b) = (b, a)
	if c > b:
		(b, c) = (c, b)
	if b > a:
		(a, b) = (b, a)
	c1 = a - b
	c2 = a - c
	n = n - c1 - c2
	if n < 0:
		print('NO')
		continue
	elif n % 3 == 0:
		print('YES')
		continue
	else:
		print('NO')
		continue


n = int(input())
s2 = []
for i in range(n):
	s1 = []
	s = input().split()
	for j in range(4):
		k = int(s[j])
		s1.append(k)
	l = max(s1[0], s1[1], s1[2])
	l1 = abs(s1[0] - l) + abs(s1[1] - l) + abs(s1[2] - l)
	l2 = s1[3] - l1
	l3 = int(l2 / 3)
	if l2 >= 0 and l3 * 3 == l2:
		s2.append('YES')
	else:
		s2.append('NO')
for item in s2:
	print(item)


from sys import stdin
t = int(stdin.readline())
for _ in range(t):
	coins = list(map(int, stdin.readline().split()))
	n = coins.pop(-1)
	p = max(coins)
	arr = [p - c for c in coins]
	r = sum(arr)
	if n - r < 0:
		print('NO')
	elif (n - r) % 3 == 0:
		print('Yes')
	else:
		print('No')


t = int(input())
for i in range(t):
	(a, b, c, n) = map(int, input().split())
	sum = a + b + c + n
	if sum % 3:
		print('NO')
	else:
		med = sum / 3
		if med < a or med < b or med < c:
			print('NO')
		else:
			print('YES')


from sys import stdin, stdout

def main():
	r = stdin.readline
	w = stdout.write
	for t in range(int(input())):
		(a, b, c, n) = map(int, r().split())
		mx = max(a, b, c)
		tmp = 3 * mx - (a + b + c)
		if n < tmp:
			w('NO\n')
		else:
			n -= tmp
			if n % 3 == 0:
				w('YES\n')
			else:
				w('NO\n')
main()


for _ in range(int(input())):
	(a, b, c, n) = map(int, input().split())
	delta = 3 * max(a, b, c) - (a + b + c)
	print('NO' if n < delta or (n - delta) % 3 else 'YES')


iterations = int(input())
for _ in range(iterations):
	(a, b, c, p) = map(int, input().split())
	highest = max(a, b, c)
	p = p - abs(a - highest) - abs(b - highest) - abs(c - highest)
	if p % 3 == 0 and p >= 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for every in range(t):
	(a, b, c, n) = input().split()
	a = int(a)
	b = int(b)
	c = int(c)
	n = int(n)
	ccheck = 0
	d = a - b
	if d < 0:
		ccheck -= d
		d = b - c
		if d < 0:
			ccheck -= d * 2
		else:
			ccheck += d
	else:
		ccheck = d
		d = a - c
		if d < 0:
			ccheck -= d * 2
		else:
			ccheck += d
	if n - ccheck >= 0:
		if (n - ccheck) % 3 == 0:
			print('YES')
			continue
	print('NO')


t = int(input())
for i in range(t):
	(A, B, C, n) = [int(x) for x in input().split()]
	x = max(A, B, C)
	tot = A + B + C + n
	if tot % 3 == 0 and tot / 3 >= x:
		print('YES')
	else:
		print('NO')


def coins(a, b, c, d):
	m = max(a, b, c)
	k = m - a + m - b + m - c
	if d < k:
		print('NO')
		return
	elif (d - k) % 3 == 0:
		print('YES')
		return
	else:
		print('NO')
		return
t = int(input())
for i in range(t):
	l_temp = input().strip().split()
	l = [int(g) for g in l_temp]
	coins(l[0], l[1], l[2], l[3])


r = int(input())
for i in range(r):
	(a, b, c, n) = map(lambda x: int(x), input().split())
	d = max(a, b, c)
	m = n - (d - a) - (d - b) - (d - c)
	if m >= 0 and m % 3 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	l = list(map(int, input().split()))
	s = sum(l)
	m = max(l[:-1])
	print('YES' if s % 3 == 0 and s // 3 >= m else 'NO')


t = int(input())
for T in range(t):
	(a, b, c, n) = tuple(map(int, input().split()))
	s = a + b + c + n
	avg = s // 3
	print('YES' if s % 3 == 0 and a <= avg and (b <= avg) and (c <= avg) else 'NO')


def isitpossible(siblings, n):
	largest = -999
	for it in siblings:
		if it > largest:
			largest = it
	for it in siblings:
		toadd = largest - it
		if toadd > n:
			return 'NO'
		n -= toadd
	if n // 3 == n / 3:
		return 'YES'
	else:
		return 'NO'
t = int(input())
for it in range(t):
	(a, b, c, n) = map(int, input().split())
	siblings = [a, b, c]
	print(isitpossible(siblings, n))


MOD = 1000000007
MOD2 = 998244353
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
for _ in range(ii()):
	(a, b, c, n) = f()
	if (a + b + c + n) % 3 == 0 and max(a, b, c) <= (a + b + c + n) // 3:
		print('YES')
	else:
		print('NO')


n1 = int(input())
while n1 > 0:
	(a, b, c, n) = [int(x) for x in input().split()]
	maximum = max(a, b, c)
	p = a + b + c + n
	if p % 3 == 0 and p / 3 >= maximum:
		print('YES')
	else:
		print('NO')
	n1 -= 1


from math import sqrt
t = int(input())
for _ in range(t):
	(a, b, c, n) = map(int, input().split())
	arr = [a, b, c]
	arr.sort(reverse=True)
	r = arr[0] - arr[1] + arr[0] - arr[2]
	r = n - r
	if r >= 0 and r % 3 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for k in range(t):
	s = str(input()).split()
	l = []
	for i in range(len(s) - 1):
		l.append(int(s[i]))
	a = int(s[-1])
	l.sort()
	if 2 * l[-1] - l[0] - l[1] > a:
		print('NO')
	elif (sum(l) + a) % 3 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(a, b, c, n) = map(int, input().split())
	m = max(a, b, c)
	d1 = abs(a - m)
	d2 = abs(b - m)
	d3 = abs(c - m)
	a = a + d1
	b = b + d2
	c = c + d3
	n = n - d1 - d2 - d3
	if n >= 0 and n % 3 == 0:
		print('YES')
	else:
		print('NO')


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

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

def si():
	return input()

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

def li():
	return list(mi())
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def getKey(item):
	return item[0]

def sort2(l):
	return sorted(l, key=getKey)

def d2(n, m, num):
	return [[num for x in range(m)] for y in range(n)]

def isPowerOfTwo(x):
	return x and (not x & x - 1)

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def ntl(n):
	return [int(i) for i in str(n)]
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
abc = 'abcdefghijklmnopqrstuvwxyz'

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

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

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 fact(n):
	f = 1
	for i in range(1, n + 1):
		f *= i
	return f

def f(n):
	a = []
	a.append(1)
	for i in range(2, int(sqrt(n)) + 1):
		if n % i == 0:
			if i == n // i:
				a.append(i)
			else:
				a.append(i)
				a.append(n // i)
	return a
t = ii()
while t:
	t -= 1
	(a, b, c, n) = mi()
	s = a + b + c + n
	if s % 3 == 0:
		x = s // 3
		if a <= x and b <= x and (c <= x):
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


from sys import stdin
from _collections import deque
mod = 10 ** 9 + 7
import sys
sys.setrecursionlimit(10 ** 5)
from queue import PriorityQueue
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, c, n) = map(int, input().split())
	(a, b, c) = sorted([a, b, c])
	n -= c - a
	n -= c - b
	a = c
	b = c
	if n >= 0:
		if (a + b + c + n) % 3 == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


flag = False
T = int(input().strip())
for i in range(T):
	given = list(map(int, input().strip().split()))
	p = given.pop()
	max_coins = max(given)
	for i in range(len(given)):
		if given[i] == max_coins:
			continue
		elif given[i] < max_coins and p != 0:
			to_give = max_coins - given[i]
			if to_give <= p:
				donation = to_give
				p = p - donation
				given[i] += donation
	if len(set(given)) == 1 and p % 3 == 0:
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	a = list(map(int, input().split()))
	(x, y, v, u) = a
	c = max(x, y, v) * 3 - x - y - v
	if sum(a) % 3 == 0 and u >= c:
		print('YES')
	else:
		print('NO')


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


n = int(input())
g = []
for _ in range(n):
	n_t = list(map(int, input().split()))
	maxx = max(n_t[:3])
	som = sum((maxx - i for i in n_t[:3]))
	tot = n_t[-1] - som
	if som > n_t[-1] or tot % 3 != 0:
		g.append('NO')
	else:
		g.append('YES')
print(*g, sep='\n')


for i in range(int(input())):
	(a, b, c, n) = map(int, input().split())
	diff = 3 * max(a, b, c) - (a + b + c)
	if n < diff:
		print('NO')
		continue
	n -= diff
	if n % 3 == 0:
		print('YES')
	else:
		print('NO')


import sys
sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep='\n')

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

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

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

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def SI():
	return sys.stdin.readline()[:-1]
n = II()
for i in range(n):
	(a, b, c, n) = LI()
	m = max(a, b, c)
	n -= m - a
	a += m - a
	n -= m - b
	b += m - b
	n -= m - c
	c += m - c
	if n >= 0 and (not n % 3):
		print('YES')
	else:
		print('NO')


testCases = int(input())
for test in range(testCases):
	case = [int(x) for x in input().split(' ')]
	a = (case[3] - 2 * case[0] + case[1] + case[2]) / 3
	b = (case[3] - 2 * case[1] + case[0] + case[2]) / 3
	c = (case[3] - 2 * case[2] + case[0] + case[1]) / 3
	if a % 1 == 0 and a >= 0 and (b % 1 == 0) and (b >= 0) and (c % 1 == 0) and (c >= 0) and (a + b + c == case[3]):
		print('YES')
	else:
		print('NO')


nn = int(input())
for tt in range(nn):
	arr1 = str(input())
	arr1 = arr1.split()
	arr = []
	for i in arr1:
		arr.append(int(i))
	a = arr[0]
	b = arr[1]
	c = arr[2]
	n = arr[3]
	total = sum(arr)
	if total % 3 != 0:
		print('NO')
		continue
	avg = int(total // 3)
	flag = 0
	for i in range(3):
		if arr[i] > avg:
			flag = 1
			break
	if flag == 1:
		print('NO')
	else:
		print('YES')


t = int(input())
lst = []
for i in range(t):
	a = input().split()
	lst.append(a)
for i in range(t):
	l = lst[i]
	for i in range(len(l)):
		l[i] = int(l[i])
	n = l[3]
	l.pop(3)
	l.sort()
	b = l[2]
	c = l[1]
	d = l[0]
	if (n - (b - c + (b - d))) % 3 == 0 and n >= b - c + (b - d):
		print('YES')
	else:
		print('NO')


import sys

def can(a, b, c, n):
	mx = max(a, b, c)
	n -= mx - a
	n -= mx - b
	n -= mx - c
	if n < 0:
		print('NO')
	elif n % 3 == 0:
		print('YES')
	else:
		print('NO')
t = int(sys.stdin.readline())
for i in range(1, t + 1):
	(A, B, C, N) = map(int, sys.stdin.readline().split())
	can(A, B, C, N)


t = int(input())
while t:
	l = list(map(int, input().split()))
	n = l[-1]
	l1 = l[:len(l) - 1]
	if l1[0] == l1[1] == l1[2]:
		if n % 3 == 0:
			print('YES')
		else:
			print('NO')
	else:
		l1.sort()
		n -= l1[-1] - l1[0]
		n -= l1[-1] - l1[1]
		if n < 0:
			print('NO')
		elif n % 3 == 0:
			print('YES')
		else:
			print('NO')
	t -= 1


t = input()
k = 0
while k < int(t):
	money = input()
	money = money.split()
	p = int(money[3])
	abc = list()
	i = 0
	while i < 3:
		abc.append(int(money[i]))
		i = i + 1
	abc.sort()
	a = int(abc[0])
	b = int(abc[1])
	c = int(abc[2])
	dif = c - a + (c - b)
	k = k + 1
	if dif > p:
		print('No')
	elif dif % 3 == p % 3:
		print('Yes')
	else:
		print('No')


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


from __future__ import division, print_function
import itertools
import sys
import os
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	input = raw_input
	range = xrange
	filter = itertools.ifilter
	map = itertools.imap
	zip = itertools.izip

def is_it_local():
	script_dir = str(os.getcwd()).split('/')
	username = 'dipta007'
	return username in script_dir

def READ(fileName):
	if is_it_local():
		sys.stdin = open(f'./{fileName}', 'r')
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 not is_it_local():
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
	input = lambda : sys.stdin.readline().rstrip('\r\n')

def input1(type=int):
	return type(input())

def input2(type=int):
	[a, b] = list(map(type, input().split()))
	return (a, b)

def input3(type=int):
	[a, b, c] = list(map(type, input().split()))
	return (a, b, c)

def input_array(type=int):
	return list(map(type, input().split()))

def input_string():
	s = input()
	return list(s)
if is_it_local():

	def debug(*args):
		st = ''
		for arg in args:
			st += f'{arg} '
		print(st)
else:

	def debug(*args):
		pass

def main():
	t = input1()
	for ci in range(t):
		[a, b, c, n] = input_array()
		mx = max(a, b, c)
		n -= mx - a
		n -= mx - b
		n -= mx - c
		if n >= 0 and n % 3 == 0:
			print('YES')
		else:
			print('NO')
	pass
main()


for _ in range(int(input())):
	l = list(map(int, input().split()))
	n = l[-1]
	l = l[:-1]
	m = max(l)
	v = [m - x for x in l]
	n = n - sum(v)
	if n < 0 or n % 3 != 0:
		print('NO')
	else:
		print('YES')


t = int(input())
for i in range(t):
	(a, b, c, n) = [int(x) for x in input().split()]
	abc = [a, b, c]
	abc.sort()
	n -= abc[2] * 2 - abc[0] - abc[1]
	if n < 0 or n % 3 != 0:
		print('NO')
	else:
		print('YES')


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


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


import sys
from collections import defaultdict as dc
import math
from bisect import bisect, bisect_left, bisect_right
input = sys.stdin.readline
for _ in range(int(input())):
	(a, b, c, n) = map(int, input().split())
	l = sorted([a, b, c], reverse=True)
	x = 2 * l[0] - l[1] - l[2]
	n -= x
	if n < 0:
		print('NO')
	elif n % 3 == 0:
		print('YES')
	else:
		print('NO')


def main():
	t = int(input())
	ans = []
	for i in range(t):
		(a, b, c, n) = map(int, input().split())
		needcoin = 3 * max(a, b, c) - sum([a, b, c])
		if n >= needcoin:
			if (n - needcoin) % 3 == 0:
				ans.append('YES')
			else:
				ans.append('NO')
		else:
			ans.append('NO')
	print(*ans, sep='\n')
main()


for i in range(int(input())):
	(a, b, c, n) = [int(i) for i in input().split()]
	arr = [a, b, c]
	arr.sort()
	(a, b, c) = arr
	n -= c - b
	n -= c - a
	if n < 0:
		print('NO')
	elif n % 3 == 0:
		print('YES')
	else:
		print('NO')


from sys import stdin
t = int(stdin.readline())
for _ in range(t):
	(a, b, c, n) = map(int, stdin.readline().split())
	m = max(a, b, c)
	r = m - a + m - b + m - c
	if n - r < 0:
		print('NO')
	elif (n - r) % 3 == 0:
		print('YES')
	else:
		print('NO')


import io
import os
from collections import Counter, defaultdict, deque

def solve(A, B, C, N):
	m = max(A, B, C)
	diff = [m - x for x in [A, B, C]]
	if N < sum(diff):
		return 'NO'
	if (N - sum(diff)) % 3 != 0:
		return 'NO'
	return 'YES'
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
T = int(input())
for t in range(T):
	(A, B, C, N) = [int(x) for x in input().split()]
	ans = solve(A, B, C, N)
	print(ans)


import sys
t = int(sys.stdin.readline())
for _ in range(t):
	(a, b, c, n) = map(int, sys.stdin.readline().split())
	m = max([a, b, c])
	to_complete = m - a + m - b + m - c
	remains = n - to_complete
	if remains >= 0 and remains % 3 == 0:
		print('YES')
	else:
		print('NO')


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


try:
	t = int(input())
	i = 0
	while i < t:
		lists = []
		(a, b, c, n) = list(map(int, input().split()))
		lists.append(a)
		lists.append(b)
		lists.append(c)
		lists.sort()
		n = n - 2 * lists[2] + lists[1] + lists[0]
		if n % 3 == 0 and n >= 0:
			print('YES')
		else:
			print('NO')
		i = i + 1
except:
	pass


t = int(input())
for p in range(t):
	(a, b, c, n) = map(int, input().split())
	s = max(a, max(b, c))
	ans = s - a + (s - b) + (s - c)
	if n < ans:
		print('NO')
	elif n == ans:
		print('YES')
	else:
		q = abs(ans - n)
		if q % 3 == 0:
			print('YES')
		else:
			print('NO')


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


t = int(input())
for i in range(t):
	(a, b, c, n) = input().split()
	a = int(a)
	b = int(b)
	c = int(c)
	n = int(n)
	t = int(n % 3)
	m = max(a, b, c)
	r = abs(m - a) + abs(m - b) + abs(m - c)
	rem = int(r % 3)
	if n >= r and rem == t:
		print('YES')
	else:
		print('NO')


t = int(input())
for each in range(t):
	flag = 0
	a = [int(i) for i in input().split()]
	n = a[3]
	s = sum(a)
	a.pop(3)
	if s % 3 == 0:
		p = s / 3
		if p < max(a):
			print('NO')
		else:
			print('YES')
	else:
		print('NO')


from bisect import bisect_left as bl
from bisect import bisect_right as br
import heapq
import math
from collections import *
from functools import reduce, cmp_to_key
import sys
input = sys.stdin.readline

def li():
	return [int(i) for i in input().rstrip('\n').split()]

def st():
	return input().rstrip('\n')

def val():
	return int(input().rstrip('\n'))

def li2():
	return [i for i in input().rstrip('\n').split(' ')]

def li3():
	return [int(i) for i in input().rstrip('\n')]
for _ in range(val()):
	(a, b, c, n) = li()
	(a, b, c) = sorted([a, b, c])
	if c - a > n:
		print('NO')
		continue
	else:
		n -= c - a
		a = c
	if c - b > n:
		print('NO')
		continue
	else:
		n -= c - b
		b = c
	if n % 3:
		print('NO')
		continue
	print('YES')


n = input()
output = []
for i in range(int(n)):
	m = list(map(int, input().strip().split()))
	ans = 'YES' if sum(m) % 3 == 0 else 'NO'
	if 3 * max(m[0:3]) - sum(m[0:3]) > m[3]:
		ans = 'NO'
	output.append(ans)
print(*output, sep='\n')


t = int(input())
results = []
for i in range(t):
	nk = list(map(int, input().split()))
	a = nk[0]
	b = nk[1]
	c = nk[2]
	n = nk[-1]
	greatest = [a, b, c]
	greatest.sort()
	num = greatest[-1] - greatest[0] + (greatest[-1] - greatest[1])
	if (n - num) % 3 == 0:
		if num > n:
			results.append('NO')
		else:
			results.append('YES')
	else:
		results.append('NO')
for i in results:
	print(i)


t = int(input())
for i in range(t):
	(a, b, c, n) = map(int, input().split())
	if a == b == c and n % 3 == 0:
		print('YES')
	else:
		q = max(a, b, c) - min(a, b, c)
		if q > n:
			print('NO')
		else:
			abc = sorted([a, b, c])
			n -= q
			abc[0] += q
			q = abc[2] - abc[1]
			if q > n:
				n = 1
			else:
				abc[1] += q
				n -= q
			if abc[0] == abc[1] == abc[2] and n % 3 == 0:
				print('YES')
			else:
				print('NO')


z = int(input())
for i in range(z):
	(a, x, c, n) = map(int, input().split())
	b = []
	b.append(a)
	b.append(x)
	b.append(c)
	b.sort()
	s = b[2] - b[0]
	d = b[2] - b[1]
	if s > n or d > n or s + d > n:
		print('NO')
	elif s <= n and d <= n and (s + d <= n):
		n = n - d - s
		if n % 3 == 0:
			print('YES')
		else:
			print('NO')
	b.clear()


def collecting_coins(a, b, c, n):
	max_value = max(a, b, c)
	coins_to_cover_diff = 3 * max_value - (a + b + c)
	if coins_to_cover_diff > n:
		return 'NO'
	a = b = c = max_value
	n = n - coins_to_cover_diff
	return 'YES' if n % 3 == 0 else 'NO'
t = int(input())
for _ in range(t):
	input_string = input()
	vals = list(map(lambda x: int(x), input_string.strip().split()))
	print(collecting_coins(vals[0], vals[1], vals[2], vals[3]))


test_cases = int(input())
for i in range(test_cases):
	all_coins = list(map(int, input().split()))
	(sis_coins, bro_coins) = (sorted(all_coins[:-1])[::-1], all_coins[-1])
	extra_coins = sis_coins[0] - sis_coins[1] + (sis_coins[0] - sis_coins[2])
	if bro_coins >= extra_coins and (bro_coins - extra_coins) % 3 == 0:
		print('YES')
	else:
		print('NO')


from collections import defaultdict as dd
from collections import Counter as ccd
from itertools import permutations as pp
from itertools import combinations as cc
from random import randint as rd
from bisect import bisect_left as bl
from bisect import bisect_right as br
import heapq as hq
from math import gcd
mod = pow(10, 9) + 7

def inp(flag=0):
	if flag == 0:
		return list(map(int, input().strip().split(' ')))
	else:
		return int(input())
t = inp(1)
while t:
	t -= 1
	(a, b, c, n) = inp()
	if (a + b + c + n) % 3 == 0 and a <= (a + b + c + n) // 3 and (b <= (a + b + c + n) // 3) and (c <= (a + b + c + n) // 3):
		print('YES')
	else:
		print('NO')


t = int(input())
if t <= 10 ** 4:
	while t > 0:
		(a, b, c, n) = input().split(' ')
		l = [int(a), int(b), int(c)]
		l.sort()
		n = int(n)
		if 2 * l[-1] - l[0] - l[1] + n >= 0:
			n = n - (2 * l[-1] - l[1] - l[0])
			if n % 3 == 0 and n >= 0:
				print('YES')
			else:
				print('NO')
		else:
			print('NO')
		t -= 1


def coins_distributed(a, b, c, n) -> str:
	sum = a + b + c + n
	if sum % 3 == 0:
		if max(a, b, c) <= sum / 3:
			return 'YES'
		else:
			return 'NO'
	else:
		return 'NO'
t = int(input())
for i in range(t):
	(a, b, c, n) = [int(x) for x in input().split(' ')]
	print(coins_distributed(a, b, c, n))


for _ in range(int(input())):
	tab = list(map(int, input().split()))
	n = tab[-1]
	tab.remove(tab[-1])
	tab.sort()
	whole = tab[-1] - tab[1] + (tab[-1] - tab[0])
	n -= whole
	if n % 3 == 0 and n >= 0:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	lst = list(map(int, input().split()))
	n = lst[-1]
	lst.pop()
	(a, b, c) = sorted(lst)
	d1 = c - a
	d2 = c - b
	n = n - d1 - d2
	if n < 0:
		print('NO')
	elif n % 3 == 0:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(a, b, c, n) = map(int, input().split())
	mx = max(a, b, c)
	s = mx - a + (mx - b) + (mx - c)
	n -= s
	if n >= 0 and n % 3 == 0:
		print('Yes')
	else:
		print('No')


def problem(a, b, c, n):
	t_coins = n
	(xa, xb, xc) = (0, 0, 0)
	max_coins = max(a, b, c)
	xa = max_coins - a
	xb = max_coins - b
	xc = max_coins - c
	dif = xa + xb + xc
	res = n - dif
	if res % 3 == 0 and res >= 0:
		print('YES')
	else:
		print('NO')

def main():
	t = int(input())
	for _ in range(t):
		(a, b, c, n) = map(int, input().split())
		problem(a, b, c, n)
main()


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__

def distribute():
	for _ in range(t):
		(a, b, c, n) = [int(x) for x in input().split()]
		if (a + b + c + n) % 3 == 0 and max(a, b, c) * 3 - sum([a, b, c]) <= n:
			yield 'YES'
		else:
			yield 'NO'
t = int(input())
ans = distribute()
print(*ans, sep='\n')


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


for ct in range(int(input())):
	li = [int(i) for i in input().split()]
	n = li[3]
	li = sorted(li[:3])
	dif = li[2] - li[0] + li[2] - li[1]
	if n < dif:
		print('NO')
	else:
		n -= dif
		if n % 3 == 0:
			print('YES')
		else:
			print('NO')


def method():
	(a, b, c, n) = map(int, input().split())
	if (a + b + c + n) % 3 != 0:
		print('NO')
	else:
		m = (a + b + c + n) // 3
		if m < a or m < b or m < c:
			print('NO')
		else:
			print('YES')
q = int(input())
for i in range(q):
	method()


for i in range(int(input())):
	a = list(map(int, input().split()))
	b = a.pop()
	boro = max(a)
	choto = min(a)
	majhari = sum(a) - boro - choto
	temp = boro - choto
	temp += boro - majhari
	b = b - temp
	if b >= 0 and b % 3 == 0:
		print('YES')
	else:
		print('NO')


from fractions import gcd
from itertools import combinations, permutations, accumulate, product
from collections import deque, defaultdict, Counter
import decimal
import re
import sys
sys.setrecursionlimit(10000000)
mod = 998244353

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

def I():
	return int(input())
for _ in range(I()):
	(a, b, c, n) = readInts()
	po = max(a, b, c)
	nya = po - a + (po - b) + (po - c)
	if n - nya < 0:
		print('NO')
	elif (n - nya) % 3:
		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')
INF = 10 ** 18
MOD = 10 ** 9 + 7
for _ in range(INT()):
	(a, b, c, N) = MAP()
	mx = max(a, b, c)
	N -= mx - a
	N -= mx - b
	N -= mx - c
	if N >= 0 and N % 3 == 0:
		YES()
	else:
		NO()


from sys import stdin
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 main():
	I = stdin.readline()
	t = int(I)
	while t != 0:
		t = t - 1
		I = stdin.readline()
		(a, b, c, n) = list(map(int, I.split()))
		each = a + b + c + n
		if each % 3 != 0:
			print('No')
			continue
		else:
			each = each / 3
			if a > each or b > each or c > each:
				print('No')
				continue
			else:
				print('Yes')
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()


t = int(input())
for i in range(t):
	(a, b, c, d) = map(int, input().split())
	status = 1
	if (a + b + c + d) % 3 == 0 and (a + b + c + d) // 3 >= max(a, b, c):
		status = 0
	print('YNEOS'[status::2])


n = int(input())
soln = []
for i in range(0, n):
	(a, b, c, n) = map(int, input().split())
	arr = [a, b, c]
	key = max(arr)
	for j in range(0, 3):
		arr[j] = abs(arr[j] - key)
	n = n - sum(arr)
	if n < 0:
		soln.append('NO')
	elif n % 3 == 0:
		soln.append('YES')
	else:
		soln.append('NO')
for i in range(0, len(soln)):
	print(soln[i])


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


t = int(input())
results = []
for i in range(t):
	(a, b, c, n) = map(int, input().split())
	if (a + b + c + n) % 3 == 0 and (a + b + c + n) // 3 >= max(a, b, c):
		results.append('YES')
	else:
		results.append('NO')
print('\n'.join(results))


t = int(input())
for _ in range(t):
	(a, b, c, n) = map(int, input().split())
	mx = max(a, b, c)
	req = mx - a + mx - b + mx - c
	n -= req
	if n < 0:
		print('NO')
	elif n % 3 == 0:
		print('YES')
	else:
		print('NO')


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


t = int(input())
for i in range(t):
	(a, b, c, n) = map(int, input().split())
	maxi = max(a, b, c)
	a1 = maxi - a
	b1 = maxi - b
	c1 = maxi - c
	z = a1 + b1 + c1
	mo = n - z
	if mo >= 0 and mo % 3 == 0:
		print('YES')
	else:
		print('NO')


def main():
	(a, b, c, n) = map(int, input().split())
	mx = max(a, max(b, c))
	add = 0
	add = mx - a + mx - b + mx - c
	n -= add
	if n >= 0 and n % 3 == 0:
		print('YES')
	else:
		print('NO')
	return

def test():
	t = int(input())
	while t:
		main()
		t -= 1
test()


n = int(input())
for i in range(0, n):
	test_case = list(map(int, input().split()))
	people = test_case[:3]
	polycarp_coin = test_case[3]
	people.sort(reverse=True)
	diff = people[0] - people[1] + (people[0] - people[2])
	if polycarp_coin < diff:
		print('NO')
	elif polycarp_coin == diff:
		print('YES')
	elif (diff - polycarp_coin) % 3 == 0:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(a, b, c, n) = map(int, input().split())
	if (a + b + c + n) % 3 == 0:
		max_coins = max(a, b, c)
		tot = abs(max_coins - a) + abs(max_coins - b) + abs(max_coins - c)
		if tot > n:
			print('NO')
		else:
			print('YES')
	else:
		print('NO')


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(a, b, c, n) = map(int, input().split())
	(d, m) = divmod(a + b + c + n, 3)
	if m == 0 and d - a >= 0 and (d - b >= 0) and (d - c >= 0):
		print('YES')
	else:
		print('NO')


result = []
for m in range(int(input())):
	(a, b, c, n) = map(int, input().split())
	ma = max(a, b, c)
	ns = ma - a + (ma - b) + (ma - c)
	if ((n - ns) % 3 == 0 or n - ns == 0) and n >= ns:
		result.append('YES')
	else:
		result.append('NO')
for e in result:
	print(e)


def solve(coins):
	output = ''
	coins[0:3] = sorted(coins[0:3])
	coins[3] -= 2 * coins[2] - coins[1] - coins[0]
	if coins[3] < 0 or coins[3] % 3 != 0:
		output += 'NO'
	else:
		output += 'YES'
	return output
t = int(input())
for i in range(t):
	array = list(map(int, input().split()))
	print(solve(array))


import sys
from collections import defaultdict
input = sys.stdin.readline
for _ in range(int(input())):
	(a, b, c, n) = map(int, input().split())
	x = max(a, b, c)
	if n >= x - a:
		n -= x - a
	else:
		print('NO')
		continue
	if n >= x - b:
		n -= x - b
	else:
		print('NO')
		continue
	if n >= x - c:
		n -= x - c
	else:
		print('NO')
		continue
	if n % 3 == 0:
		print('YES')
	else:
		print('NO')


import sys
input = sys.stdin.readline
from math import *
t = int(input())
while t > 0:
	t -= 1
	(a, b, c, n) = map(int, input().split())
	p = a + b + c + n
	if p % 3 != 0:
		print('NO')
		continue
	m = max(a, max(b, c))
	if p // 3 < m:
		print('NO')
		continue
	print('YES')


def answer():
	n = int(input())
	for i in range(n):
		num = [int(x) for x in input().split()]
		dif = 0
		max_el = max(num[:-1])
		for i in num[:-1]:
			dif += max_el - i
		if (num[-1] - dif) % 3 == 0 and num[-1] - dif >= 0:
			print('YES')
		else:
			print('NO')
answer()


def coin(a, b, c, n):
	maxi = max(a, b, c)
	x = maxi - a
	y = maxi - b
	z = maxi - c
	n = n - x - y - z
	if n >= 0 and n % 3 == 0:
		return 'YES'
	return 'NO'
t = int(input())
for i in range(t):
	(a, b, c, n) = map(int, input().split())
	print(coin(a, b, c, n))


exec(int(input()) * "a=*map(int,input().split()),;s=sum(a);print('YNEOS'[s%-3|s-3*max(a[:3])<0::2]);")


t = int(input())
while t > 0:
	lis = list(map(int, input().split()))
	m = max(lis[:3])
	s = sum(lis[:3])
	rem = lis[3] - (3 * m - s)
	if rem >= 0 and rem % 3 == 0:
		print('YES')
	else:
		print('NO')
	t -= 1


for _ in range(int(input())):
	l = list(map(int, input().split()))
	k = max(l[:3])
	ans = 3 * k - sum(l[:3])
	if ans > l[-1]:
		print('No')
		continue
	if l[-1] - ans == 0 or (l[-1] - ans) % 3 == 0:
		print('YES')
		continue
	print('No')


for i in range(int(input())):
	a = list(map(int, input().strip().split()))[:4]
	sum = a[0] + a[1] + a[2] + a[3]
	if sum % 3 != 0:
		print('NO')
	else:
		avg = int(sum / 3)
		if avg < a[0] or avg < a[1] or avg < a[2]:
			print('NO')
		else:
			print('YES')


import sys
t = int(input())
while t > 0:
	t = t - 1
	(a, b, c, n) = input().strip().split()
	a = int(a)
	b = int(b)
	c = int(c)
	n = int(n)
	x = max(a, b, c)
	if n >= 0:
		a = x - a
		s1 = n - a
		if s1 < 0:
			print('NO')
			continue
		else:
			n = n - a
	if n >= 0:
		b = x - b
		s2 = n - b
		if s2 < 0:
			print('NO')
			continue
		else:
			n = n - b
	if n >= 0:
		c = x - c
		s3 = n - c
		if s3 < 0:
			print('NO')
			continue
		else:
			n = n - c
	if n >= 0:
		if n % 3 == 0:
			print('YES')
		else:
			print('NO')


a = int(input())
q = []
e = []
for i in range(1, a + 1):
	b = input().split()
	c_1 = b[0:3]
	c_2 = int(b[3])
	for z in c_1:
		q.append(int(z))
	w = 3 * max(q) - (q[0] + q[1] + q[2])
	r = c_2 - w
	if r >= 0 and r % 3 == 0:
		e.append('YES')
	else:
		e.append('NO')
	q.clear()
for v in e:
	print(v)


t = int(input())
d = []
for i in range(0, t):
	a = input()
	d.append(a.split())
for j in range(0, t):
	d2 = [int(y) for y in d[j]]
	n = d2[3]
	d1 = [d2[0], d2[1], d2[2]]
	d1.sort()
	a = d1[2] - d1[0]
	b = d1[2] - d1[1]
	n = n - a - b
	if n >= 0 and n % 3 == 0:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(a, b, c, n) = map(int, input().split(' '))
	(a, b, c) = sorted([a, b, c])
	C = (n - 2 * c + a + b) / 3
	if float(C).is_integer() and C >= 0:
		print('YES')
	else:
		print('NO')


import sys
numtest = int(sys.stdin.readline())
for _ in range(numtest):
	(alice, barbara, cerene, poly) = [int(i) for i in sys.stdin.readline().strip().split(' ')]
	print('YNEOS'[not ((alice + barbara + cerene + poly) % 3 == 0 and max(alice, barbara, cerene) <= (alice + barbara + cerene + poly) // 3)::2])


t = int(input())
lst = []
for i in range(t):
	lst.append(input())
for a in lst:
	b = str(a)
	c = b.split()
	d = []
	for j in c:
		d.append(int(j))
	e = sum(d)
	if e % 3 == 0:
		e = e / 3
		if e >= d[0] and e >= d[1] and (e >= d[2]):
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


def collect_coins(a, b, c, n):
	max_ = max(a, b, c)
	value = max_ - a + (max_ - b) + (max_ - c)
	if n - value < 0:
		return False
	elif (n - value) % 3 != 0:
		return False
	else:
		return True
t = int(input())
for i in range(t):
	(a, b, c, n) = map(int, input().split())
	if collect_coins(a, b, c, n):
		print('YES')
	else:
		print('NO')


Test = int(input())
while Test > 0:
	(a, b, c, n) = map(int, input().split())
	temp = 0
	mx = max(a, b, c)
	if a < mx:
		temp += mx - a
	if b < mx:
		temp += mx - b
	if c < mx:
		temp += mx - c
	if n < temp:
		print('NO')
	elif n == temp:
		print('YES')
	elif (n - temp) % 3 == 0:
		print('YES')
	else:
		print('NO')
	Test -= 1


t = int(input())
for i in range(t):
	data = input().split(' ')
	data = list(map(int, data))
	avg = sum(data) / 3
	if sum(data) % 3 == 0 and avg >= data[0] and (avg >= data[1]) and (avg >= data[2]):
		print('YES')
	else:
		print('NO')


import math
t = int(input())
for _ in range(t):
	(a, c, b, n) = map(int, input().split())
	mx = max(a, b, c)
	sm = 0
	if a != mx:
		sm += mx - a
	if b != mx:
		sm += mx - b
	if c != mx:
		sm += mx - c
	sm = n - sm
	if sm == 0:
		print('YES')
		continue
	if sm < 0:
		print('NO')
		continue
	if sm % 3 == 0:
		print('YES')
	else:
		print('NO')


for __ in range(int(input())):
	arr = [int(s) for s in input().split()]
	n = arr[3]
	arr = arr[:3]
	arr.sort()
	if n < 2 * arr[2] - arr[1] - arr[0]:
		print('NO')
	elif (n - (2 * arr[2] - arr[1] - arr[0])) % 3 == 0:
		print('Yes')
	else:
		print('NO')


from sys import stdin

def main():
	input = lambda : stdin.readline()[:-1]
	T = int(input())
	for _ in [0] * T:
		(A, B, C, N) = map(int, input().split())
		abc = sorted([A, B, C])
		x = abc[2] - abc[0] + abc[2] - abc[1]
		if x <= N and (not (x - N) % 3):
			print('YES')
		else:
			print('NO')
main()


n = int(input())
for _ in range(n):
	a = [int(i) for i in input().split()]
	aa = a.pop(3)
	a.sort()
	ans = a[2] - a[1] + a[2] - a[0]
	aa -= ans
	if aa >= 0:
		if aa % 3 == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


t = int(input())
result = []
for _ in range(t):
	abcn = list(map(int, input().split()))
	(abc, n) = (abcn[:3], abcn[3])
	abc.sort()
	val = n - (abc[2] - abc[1] + (abc[2] - abc[0]))
	if val >= 0 and val % 3 == 0:
		result.append('YES')
	else:
		result.append('NO')
for i in result:
	print(i)


t = int(input())
for i in range(0, t):
	(a, b, c, n) = (int(k) for k in input().split())
	mac = 0
	if a >= b and a >= c:
		mac = a
	elif b >= a and b >= c:
		mac = b
	else:
		mac = c
	test = n - 3 * mac + a + b + c
	if test < 0 or test % 3 != 0:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	abcn = list(map(int, input().split()))
	maxABC = max(abcn[0:3])
	Diff = [maxABC - abcn[i] for i in range(3)]
	sumDiff = sum(Diff)
	if sumDiff == abcn[3]:
		print('YES')
	elif sumDiff < abcn[3]:
		if (abcn[3] - sumDiff) % 3 == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


from sys import stdin, stdout
import sys
INF = 1000000000.0
import bisect

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

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

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

def get_string():
	return stdin.readline().strip()

def op(c):
	return stdout.write(c)
for _ in range(int(stdin.readline())):
	(a, b, c, n) = get_ints()
	m = max(a, b, c)
	d = m - a + (m - b) + (m - c)
	if d > n:
		print('NO')
	else:
		n = n - d
		if n % 3 == 0:
			print('YES')
		else:
			print('NO')


t = int(input())
while t > 0:
	(X, Y, Z, n) = input().split()
	X = int(X)
	Y = int(Y)
	Z = int(Z)
	n = int(n)
	y = (X + n + Z - 2 * Y) / 3
	if y >= 0 and y.is_integer():
		z = Y + y - Z
		x = Y + y - X
		if z >= 0 and x >= 0 and (x + y + z == n):
			print('YES')
		else:
			print('NO')
	else:
		print('NO')
	t = t - 1


import math

def mergeSort(lst):
	if len(lst) <= 1:
		return lst
	mid = math.floor(len(lst) / 2)
	left = mergeSort(lst[0:mid])
	right = mergeSort(lst[mid:])
	return merge(left, right)

def merge(arr1, arr2):
	i = 0
	j = 0
	lst = []
	while i < len(arr1) and j < len(arr2):
		if arr1[i] < arr2[j]:
			lst.append(arr1[i])
			i += 1
		else:
			lst.append(arr2[j])
			j += 1
	while i < len(arr1):
		lst.append(arr1[i])
		i += 1
	while j < len(arr2):
		lst.append(arr2[j])
		j += 1
	return lst
test = int(input())
i = 0
while i < test:
	(a, b, c, n) = input().split()
	a = int(a)
	b = int(b)
	c = int(c)
	n = int(n)
	lst = [a, b, c]
	lst = mergeSort(lst)
	diff1 = lst[2] - lst[0]
	diff2 = lst[2] - lst[1]
	left = diff1 + diff2
	n = n - left
	if n < 0:
		print('NO')
	elif n % 3 == 0:
		print('YES')
	else:
		print('NO')
	i += 1


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


def collectingCoins(a, b, c, n):
	li = sorted([a, b, c], reverse=True)
	if n - (li[0] - li[2] + (li[0] - li[1])) < 0 or (n - (li[0] - li[2] + (li[0] - li[1]))) % 3 != 0:
		return 'NO'
	return 'YES'
for i in range(int(input())):
	(a, b, c, n) = map(int, input().split())
	print(collectingCoins(a, b, c, n))


a = int(input())
for i in range(a):
	(a, b, c, n) = map(int, input().split())
	lis = []
	lis.append(a)
	lis.append(b)
	lis.append(c)
	lis.sort()
	sw = 0
	for i in range(1):
		if lis[0] == lis[1] and lis[1] == lis[2]:
			s = sum(lis) + n
			if s % 3 == 0:
				sw = 1
			break
		else:
			while lis[0] < lis[2] and n != 0:
				r = lis[2] - lis[0]
				n = n - r
				if n >= 0:
					lis[0] = lis[0] + r
				else:
					break
			while lis[1] < lis[2] and n != 0:
				r1 = lis[2] - lis[1]
				n = n - r1
				if n >= 0:
					lis[1] = lis[1] + r1
				else:
					break
			if lis[0] == lis[1] and lis[1] == lis[2]:
				s = sum(lis) + n
				if s % 3 == 0:
					sw = 1
				break
	if sw == 1:
		print('YES')
	else:
		print('NO')


import statistics as stat
t = int(input())
for _ in range(t):
	(a, b, c, n) = map(int, input().split())
	mini = min([a, b, c])
	maxi = max([a, b, c])
	mid = stat.median([a, b, c])
	s = 2 * maxi - mini - mid
	f = 1
	if n < s:
		f = 0
	if f == 1:
		s = s % 3
		n = n - s
	if n % 3 == 0 and f == 1:
		print('YES')
	else:
		print('NO')


import sys

def solution(a, b, c, n):
	(a, b, c) = sorted([a, b, c])
	su = a + b + c + n
	if su % 3 != 0:
		return 'NO'
	if c > su // 3:
		return 'NO'
	else:
		return 'YES'
for line in sys.stdin:
	t = int(line)
	break
for line in sys.stdin:
	(a, b, c, n) = [int(x) for x in line.split()]
	res = solution(a, b, c, n)
	print(res)


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


q = int(input())
for i in range(q):
	(z, d, p, w) = map(int, input().split())
	k = max(z, d, p)
	s = k - z + (k - d) + (k - p)
	r = w - s
	if w >= s and r % 3 == 0:
		print('YES')
	else:
		print('NO')


T = int(input())
for _ in range(T):
	(a, b, c, n) = map(int, input().split())
	most = max(a, b, c)
	coins_needed_for_even = most - a + (most - b) + (most - c)
	remaining_coins = n - coins_needed_for_even
	if remaining_coins >= 0 and remaining_coins % 3 == 0:
		print('YES')
	else:
		print('NO')


def nod(a, b):
	while a != b:
		(a, b) = (max(a, b), min(a, b))
		if a % b == 0:
			a -= (a // b - 1) * b
		else:
			a -= a // b * b
	return a
for t in range(int(input())):
	(a, b, c, n) = [int(x) for x in input().split()]
	(a, b, c) = sorted([a, b, c])
	n -= 2 * c - a - b
	print('NO' if n < 0 or n % 3 != 0 else 'YES')


test_case = int(input())
for i in range(test_case):
	values = list(map(int, input().split(' ')))
	poly = values[3]
	values.remove(poly)
	values.sort()
	poly = poly - (values[2] - values[1]) - (values[2] - values[0])
	if poly % 3 == 0 and poly >= 0:
		print('YES')
	else:
		print('NO')


from sys import stdin as cin, stdout as cout

def main():
	t = int(input())
	answer = []
	for i in range(t):
		(a, b, c, n) = list(map(int, input().split()))
		flag = True
		if (a + b + c + n) % 3 != 0:
			flag = False
			answer.append('NO')
		else:
			target = (a + b + c + n) // 3
			if target - a < 0 or target - b < 0 or target - c < 0:
				answer.append('NO')
			else:
				answer.append('YES')
	print(*answer, sep='\n')
main()


for i in range(int(input())):
	arr = [int(i) for i in input().split()]
	if sum(arr) % 3 == 0 and sum(arr) / 3 >= max(arr[:3]):
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = list(map(int, input().split()))
	if n[3] == 0:
		print('NO')
	elif sum(n) % 3 == 0:
		flag = 0
		for i in range(3):
			if n[i] > int(sum(n) / 3):
				flag = 1
				break
		if flag == 0:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(a, b, c, n) = map(int, input().split())
	if a == b == c:
		if n % 3 == 0:
			print('YES')
		else:
			print('NO')
	elif (a + b + c + n) % 3 == 0:
		ns = [a, b, c]
		ns.sort()
		if ns[2] - ns[1] + (ns[2] - ns[0]) <= n:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


n = int(input())
for k in range(n):
	a = list(map(int, input().split()))
	if sum(a) % 3 == 0 and sum(a) // 3 >= a[0] and (sum(a) // 3 >= a[1]) and (sum(a) // 3 >= a[2]):
		print('YES')
	else:
		print('NO')


class Solution:

	def solve(self, a, b, c, n):
		mList = sorted([a, b, c])
		totalCoinsRequired = 0
		for i in range(2):
			totalCoinsRequired += mList[2] - mList[i]
		if totalCoinsRequired > n or (n - totalCoinsRequired) % 3 != 0:
			return False
		return True
sol = Solution()
t = int(input().strip())
for i in range(t):
	[a, b, c, n] = list(map(int, input().strip().split()))
	print('YES' if sol.solve(a, b, c, n) else 'NO')


t = int(input())
num = [0, 0, 0]
for x in range(0, t):
	(num[0], num[1], num[2], n) = input().split()
	num = [int(r) for r in num]
	n = int(n)
	num.sort()
	diff = num[2] - num[0] + num[2] - num[1]
	n1 = n - diff
	r = n1 % 3
	if r == 0 and n1 >= 0 or n == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(a, b, c, n) = map(int, input().split(' '))
	l = sorted([a, b, c])
	t1 = l[2] - l[0]
	t2 = l[2] - l[1]
	n -= t1 + t2
	if n < 0:
		print('NO')
	elif n % 3 == 0:
		print('YES')
	else:
		print('NO')


from sys import stdin, stdout
t = int(stdin.readline().strip())
for _ in range(t):
	(a, b, c, n) = map(int, stdin.readline().split())
	d = max([a, b, c])
	n -= 3 * d - a - b - c
	if n < 0 or n % 3:
		stdout.write('NO\n')
	else:
		stdout.write('YES\n')


for _ in range(int(input())):
	(a, b, c, n) = map(int, input().split())
	max_coins = max(a, b, c)
	req = 3 * max_coins - a - b - c
	if req > n:
		print('NO')
		continue
	else:
		left = req - n
		if left % 3 == 0:
			print('YES')
		else:
			print('NO')


t = int(input())
for _ in range(t):
	(a, b, c, n) = [int(x) for x in input().split()]
	mn = (a + b + c + n) // 3
	if 3 * mn == a + b + c + n and a <= mn and (b <= mn) and (c <= mn):
		print('YES')
	else:
		print('NO')


import sys
t = int(input())
while t >= 1:
	t = t - 1
	(a, b, c, n) = map(int, sys.stdin.readline().split(' '))
	sum = a + b + c + n
	each = sum / 3
	if sum % 3 == 0:
		if each < a or each < b or each < c:
			print('NO')
		else:
			print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	a = [*map(int, input().split())]
	s = sum(a)
	if s % 3 == 0:
		m = max(a[:-1])
		diff = 0
		for i in range(3):
			diff += m - a[i]
		if diff <= a[-1]:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


hm = int(input())
for i in range(hm):
	(a, b, c, n) = map(int, input().split())
	diva = (a + b + c + n) / 3
	if diva % 1 == 0 and diva >= max(a, b, c):
		print('YES')
	else:
		print('NO')


a = int(input())
for k in range(a):
	(a, b, c, d) = list(map(int, input().split(' ')))
	e = max(a, b, c)
	if (a + b + c + d) % 3 == 0 and (a + b + c + d) // 3 >= e:
		print('YES')
	else:
		print('NO')


t = int(input())
while t:
	t -= 1
	q = list(map(int, input().split()))
	n = q[3]
	res = q[0:3]
	res.sort()
	c = 0
	c += res[2] - res[1]
	c += res[2] - res[0]
	if c > n:
		print('NO')
	elif c <= n and int((n - c) % 3) == 0:
		print('YES')
	else:
		print('NO')