Uncle Bogdan is in captain Flint's crew for a long time and sometimes gets nostalgic for his homeland. Today he told you how his country introduced a happiness index.

There are $n$ cities and $n−1$ undirected roads connecting pairs of cities. Citizens of any city can reach any other city traveling by these roads. Cities are numbered from $1$ to $n$ and the city $1$ is a capital. In other words, the country has a tree structure.

There are $m$ citizens living in the country. A $p_i$ people live in the $i$-th city but all of them are working in the capital. At evening all citizens return to their home cities using the shortest paths. 

Every person has its own mood: somebody leaves his workplace in good mood but somebody are already in bad mood. Moreover any person can ruin his mood on the way to the hometown. If person is in bad mood he won't improve it.

Happiness detectors are installed in each city to monitor the happiness of each person who visits the city. The detector in the $i$-th city calculates a happiness index $h_i$ as the number of people in good mood minus the number of people in bad mood. Let's say for the simplicity that mood of a person doesn't change inside the city.

Happiness detector is still in development, so there is a probability of a mistake in judging a person's happiness. One late evening, when all citizens successfully returned home, the government asked uncle Bogdan (the best programmer of the country) to check the correctness of the collected happiness indexes.

Uncle Bogdan successfully solved the problem. Can you do the same?

More formally, You need to check: "Is it possible that, after all people return home, for each city $i$ the happiness index will be equal exactly to $h_i$".


-----Input-----

The first line contains a single integer $t$ ($1 \le t \le 10000$) — the number of test cases.

The first line of each test case contains two integers $n$ and $m$ ($1 \le n \le 10^5$; $0 \le m \le 10^9$) — the number of cities and citizens.

The second line of each test case contains $n$ integers $p_1, p_2, \ldots, p_{n}$ ($0 \le p_i \le m$; $p_1 + p_2 + \ldots + p_{n} = m$), where $p_i$ is the number of people living in the $i$-th city.

The third line contains $n$ integers $h_1, h_2, \ldots, h_{n}$ ($-10^9 \le h_i \le 10^9$), where $h_i$ is the calculated happiness index of the $i$-th city.

Next $n − 1$ lines contain description of the roads, one per line. Each line contains two integers $x_i$ and $y_i$ ($1 \le x_i, y_i \le n$; $x_i \neq y_i$), where $x_i$ and $y_i$ are cities connected by the $i$-th road.

It's guaranteed that the sum of $n$ from all test cases doesn't exceed $2 \cdot 10^5$.


-----Output-----

For each test case, print YES, if the collected data is correct, or NO — otherwise. You can print characters in YES or NO in any case.


-----Examples-----
Input
2
7 4
1 0 1 1 0 1 0
4 0 0 -1 0 -1 0
1 2
1 3
1 4
3 5
3 6
3 7
5 11
1 2 5 2 1
-11 -2 -6 -2 -1
1 2
1 3
1 4
3 5

Output
YES
YES

Input
2
4 4
1 1 1 1
4 1 -3 -1
1 2
1 3
1 4
3 13
3 3 7
13 1 4
1 2
1 3

Output
NO
NO



-----Note-----

Let's look at the first test case of the first sample:  [Image] 

At first, all citizens are in the capital. Let's describe one of possible scenarios:   a person from city $1$: he lives in the capital and is in good mood;  a person from city $4$: he visited cities $1$ and $4$, his mood was ruined between cities $1$ and $4$;  a person from city $3$: he visited cities $1$ and $3$ in good mood;  a person from city $6$: he visited cities $1$, $3$ and $6$, his mood was ruined between cities $1$ and $3$;  In total,   $h_1 = 4 - 0 = 4$,  $h_2 = 0$,  $h_3 = 1 - 1 = 0$,  $h_4 = 0 - 1 = -1$,  $h_5 = 0$,  $h_6 = 0 - 1 = -1$,  $h_7 = 0$. 

The second case of the first test:  $\text{of}_{0}$ 

All people have already started in bad mood in the capital — this is the only possible scenario.

The first case of the second test:  $\text{of} 0$ 

The second case of the second test:  [Image] 

It can be proven that there is no way to achieve given happiness indexes in both cases of the second test.

Source: codeforces | Difficulty: MEDIUM_HARD
Tags: Tree algorithms

Graph traversal

Mathematics

Greedy algorithms


Solutions:
import sys
sys.setrecursionlimit(1000000)
input = sys.stdin.buffer.readline
t = int(input())
for zzz in range(t):
	(n, m) = [int(x) for x in input().split()]
	p = [int(x) for x in input().split()]
	h = [int(x) for x in input().split()]
	p.insert(0, 0)
	h.insert(0, 0)
	edges = [[] for _ in range(n + 1)]
	for zz in range(n - 1):
		(u, v) = [int(x) for x in input().split()]
		edges[u].append(v)
		edges[v].append(u)
	ok = [True]

	def dfs(node, parent):
		T = p[node]
		minH = 0
		for nextt in edges[node]:
			if nextt != parent:
				(a, b) = dfs(nextt, node)
				T += a
				minH += b
		temp = h[node] + T
		if temp % 2 == 1:
			ok[0] = False
		actualH = temp // 2
		actualS = T - actualH
		if actualH < 0 or actualS < 0:
			ok[0] = False
		if actualH < minH:
			ok[0] = False
		return (T, actualH)
	dfs(1, 0)
	if ok[0]:
		print('YES')
	else:
		print('NO')


import sys
sys.setrecursionlimit(10 ** 7)

def solve():
	(N, M) = map(int, input().split())
	person = list(map(int, input().split()))
	happy = list(map(int, input().split()))
	G = [[] for i in range(N + 1)]
	for i in range(N - 1):
		(x, y) = map(int, input().split())
		G[x].append(y)
		G[y].append(x)
	visited = [False for i in range(N + 1)]
	depth = [0 for i in range(N + 1)]
	child_cnt = [person[i - 1] for i in range(N + 1)]

	def dfs(s_node):
		visited[s_node] = True
		for child in G[s_node]:
			if visited[child] == False:
				depth[child] = depth[s_node] + 1
				dfs(child)
		for child in G[s_node]:
			if depth[child] > depth[s_node]:
				child_cnt[s_node] += child_cnt[child]
	dfs(1)
	good_count = [0 for i in range(N + 1)]
	flag = True
	for i in range(N):
		if (child_cnt[i + 1] + happy[i]) % 2 != 0:
			flag = False
			break
		else:
			good_count[i + 1] = (child_cnt[i + 1] + happy[i]) // 2
	if flag == False:
		print('NO')
		return
	for i in range(1, N + 1):
		left = good_count[i]
		if not 0 <= left <= child_cnt[i]:
			flag = False
			break
		right = 0
		for child in G[i]:
			if depth[i] < depth[child]:
				right += good_count[child]
		if left < right:
			flag = False
			break
	if flag:
		print('YES')
	else:
		print('NO')
	return

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


import sys
sys.setrecursionlimit(5100)

def f(u, x):
	g[u] -= {x}
	for v in g[u]:
		f(v, u)
		p[u] += p[v]
	h[u] += p[u]
	r[0] &= h[u] % 2 < 1 and sum((h[v] for v in g[u])) <= h[u] <= 2 * p[u]
R = lambda : map(int, input().split())
(t,) = R()
for _ in [0] * t:
	(n, m) = R()
	p = [0, *R()]
	h = [0, *R()]
	r = [1]
	g = r + [set() for _ in r * n]
	for _ in r * (n - 1):
		(x, y) = R()
		g[x] |= {y}
		g[y] |= {x}
	f(1, 0)
	print('NYOE S'[r[0]::2])


import sys
input = sys.stdin.buffer.readline
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	P = list(map(int, input().split()))
	H = list(map(int, input().split()))
	g = [[] for _ in range(n)]
	for i in range(n - 1):
		(x, y) = map(int, input().split())
		(x, y) = (x - 1, y - 1)
		g[x].append(y)
		g[y].append(x)
	s = []
	s.append(0)
	parent = [-1] * n
	order = []
	while s:
		x = s.pop()
		order.append(x)
		for nx in g[x]:
			if nx == parent[x]:
				continue
			parent[nx] = x
			s.append(nx)
	order.reverse()
	C = [0] * n
	for v in order:
		C[v] += P[v]
		if parent[v] != -1:
			C[parent[v]] += C[v]
	B = [10 ** 18] * n
	flag = True
	for v in order:
		x = C[v]
		h = H[v]
		b = B[v]
		if (x - h) % 2 == 1:
			flag = False
			break
		else:
			y = (x - h) // 2
			if y > x or y < 0:
				flag = False
				break
			p = P[v]
			if y - p > b:
				flag = False
				break
			elif parent[v] != -1:
				if B[parent[v]] == 10 ** 18:
					B[parent[v]] = y
				else:
					B[parent[v]] += y
	if flag:
		print('YES')
	else:
		print('NO')


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(N, M) = map(int, input().split())
	p = [0] + list(map(int, input().split()))
	h = [0] + list(map(int, input().split()))
	e = [[] for _ in range(N + 1)]
	for _ in range(N - 1):
		(u, v) = map(int, input().split())
		e[u].append(v)
		e[v].append(u)
	s = [1]
	order = [1]
	parent = [0] * (N + 1)
	size = [0] * (N + 1)
	vis = [0] * (N + 1)
	while len(s):
		x = s.pop()
		vis[x] = 1
		for y in e[x]:
			if vis[y]:
				continue
			parent[y] = x
			order.append(y)
			s.append(y)
			vis[y] = 1
	order.reverse()
	gg = [0] * (N + 1)
	bb = [0] * (N + 1)
	res = 1
	for i in range(1, N + 1):
		size[i] = p[i]
	for y in order:
		x = parent[y]
		size[x] += size[y]
	for y in order:
		x = parent[y]
		b = (size[y] - h[y]) // 2
		g = size[y] - b
		if b < 0 or g < 0:
			res = 0
			break
		if (size[y] - h[y]) % 2:
			res = 0
			break
		if bb[y] + p[y] >= b:
			if bb[y] + p[y] - b + gg[y] == g:
				gg[x] += g
				bb[x] += b
			else:
				res = 0
				break
		else:
			res = 0
			break
	if res:
		print('YES')
	else:
		print('NO')


def main():
	import sys
	input = sys.stdin.buffer.readline
	t = int(input())
	for _ in range(t):
		(n, m) = map(int, input().split())
		p = list(map(int, input().split()))
		h = list(map(int, input().split()))
		G = [set() for i in range(n)]
		for i in range(n - 1):
			(x, y) = map(int, input().split())
			x -= 1
			y -= 1
			G[x].add(y)
			G[y].add(x)
		flag = True
		r = set()
		r.add(0)
		arr = [0]
		id = 0
		for id in range(n):
			x = arr[id]
			for y in G[x]:
				if y in r:
					continue
				else:
					r.add(y)
					arr.append(y)
		r = set()
		D = [0 for i in range(n)]
		for x in arr[::-1]:
			r.add(x)
			if abs(h[x]) > p[x] or (h[x] + p[x]) % 2 == 1:
				flag = False
				break
			H = (h[x] + p[x]) // 2
			if H < D[x]:
				flag = False
				break
			for y in G[x]:
				if y in r:
					continue
				else:
					p[y] += p[x]
					D[y] += H
					break
		if flag:
			print('YES')
		else:
			print('NO')
main()


import sys
sys.setrecursionlimit(5056)

def f(u, x):
	s = 0
	for v in g[u]:
		if v ^ x:
			f(v, u)
			p[u] += p[v]
			s += p[v] + h[v]
	q = h[u] + p[u]
	p[0] &= ~q & (s <= q <= 2 * p[u])
R = lambda : map(int, input().split())
(t,) = R()
for _ in [0] * t:
	R()
	p = [1, *R()]
	h = (0, *R())
	g = [[] for _ in p]
	for _ in p[2:]:
		(x, y) = R()
		g[x] += (y,)
		g[y] += (x,)
	f(1, 0)
	print('NYOE S'[p[0]::2])


from sys import stdin, stdout
for query in range(int(stdin.readline())):
	nm = stdin.readline().split()
	n = int(nm[0])
	m = int(nm[1])
	populations = [int(x) for x in stdin.readline().split()]
	happiness = [int(x) for x in stdin.readline().split()]
	adjacency = [[] for x in range(n)]
	for x in range(n - 1):
		pair = [int(x) for x in stdin.readline().split()]
		adjacency[pair[0] - 1].append(pair[1] - 1)
		adjacency[pair[1] - 1].append(pair[0] - 1)
	travelled = [0] * n
	visit = [0]
	dist = [-1] * n
	children = [[] for x in range(n)]
	parents = [0] * n
	curr_dist = 0
	while len(visit) > 0:
		visitnext = []
		for node in visit:
			dist[node] = curr_dist
			for other_node in adjacency[node]:
				if dist[other_node] == -1:
					visitnext.append(other_node)
					children[node].append(other_node)
					parents[other_node] = node
		visit = visitnext
		curr_dist += 1
	distances = [[] for x in range(n)]
	for node in range(n):
		distances[dist[node]].append(node)
	for node in range(n):
		travelled[node] += populations[node]
	for generation in range(n - 1, 0, -1):
		for node in distances[generation]:
			travelled[parents[node]] += travelled[node]
	sadness = [0] * n
	mybool = True
	for node in range(n):
		if (travelled[node] + happiness[node]) % 2 == 1:
			mybool = False
			break
		sadness[node] = (travelled[node] - happiness[node]) // 2
	for node in range(n):
		if abs(happiness[node]) > travelled[node]:
			mybool = False
	for node in range(n):
		total = 0
		for node2 in children[node]:
			total += sadness[node2]
		if sadness[node] > total + populations[node]:
			mybool = False
			break
	if mybool:
		stdout.write('YES\n')
	else:
		stdout.write('NO\n')


import sys
input = sys.stdin.buffer.readline

def process(P, H, G, n):
	g = {i: [set([]), None, 0, 0] for i in range(1, n + 1)}
	for (a, b) in G:
		g[a][0].add(b)
		g[b][0].add(a)
	start = [1]
	L = [1]
	while len(start) > 0:
		next_s = []
		for x in start:
			for y in g[x][0]:
				if y != g[x][1]:
					next_s.append(y)
					L.append(y)
					g[y][0].remove(x)
					g[y][1] = x
		start = next_s
	while len(L) > 0:
		x = L[-1]
		own = P[x - 1]
		children = 0
		happy = 0
		unhappy = 0
		for y in g[x][0]:
			happy1 = g[y][2]
			unhappy1 = g[y][3]
			happy += happy1
			unhappy += unhappy1
			children += happy1 + unhappy1
		if (own + children) % 2 != H[x - 1] % 2:
			return 'NO'
		happy_goal = (own + children + H[x - 1]) // 2
		unhappy_goal = (own + children - H[x - 1]) // 2
		if happy_goal < happy or unhappy_goal < 0 or unhappy - children + happy_goal < 0:
			return 'NO'
		g[x][2] = happy_goal
		g[x][3] = unhappy_goal
		L.pop()
	return 'YES'
t = int(input())
for i in range(t):
	(n, m) = [int(x) for x in input().split()]
	P = [int(x) for x in input().split()]
	H = [int(x) for x in input().split()]
	G = []
	for i in range(n - 1):
		(a, b) = [int(x) for x in input().split()]
		G.append([a, b])
	answer = process(P, H, G, n)
	sys.stdout.write(answer + '\n')


import sys, collections, bisect
input = sys.stdin.buffer.readline
que = collections.deque
vector = collections.defaultdict
bsearch = bisect.bisect
inin = lambda : int(input())
inar = lambda : list(map(int, input().split()))
INF = float('inf')
from types import GeneratorType

def bootstrap(f, stack=[]):

	def wrappedfunc(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		else:
			to = f(*args, **kwargs)
			while True:
				if type(to) is GeneratorType:
					stack.append(to)
					to = next(to)
				else:
					stack.pop()
					if not stack:
						break
					to = stack[-1].send(to)
			return to
	return wrappedfunc
ans = ''

@bootstrap
def dfs(graph, node, par, vis, h, p):
	global ans
	check = 0
	vis[node] = p[node]
	for child in graph[node]:
		if child != par:
			vis[node] += (yield dfs(graph, child, node, vis, h, p))
			check += h[child]
	if (vis[node] + h[node]) % 2:
		ans = 'NO'
	if abs(h[node]) > vis[node]:
		ans = 'NO'
	if check > p[node] + h[node]:
		ans = 'NO'
	yield vis[node]
Testcase = inin()
for Case in range(Testcase):
	ans = 'YES'
	(n, m) = inar()
	p = [0] + inar()
	h = [m + 8] + inar()
	vis = [0 for i in range(n + 1)]
	graph = [[] for i in range(n + 1)]
	for i in range(n - 1):
		(a, b) = inar()
		graph[a].append(b)
		graph[b].append(a)
	dfs(graph, 1, 0, vis, h, p)
	print(ans)


import sys
import collections
input = sys.stdin.readline

def main():
	t = int(input())
	for _ in range(t):
		(N, M) = [int(x) for x in input().split()]
		P = [int(x) for x in input().split()]
		H = [int(x) for x in input().split()]
		XY = [[int(x) for x in input().split()] for _ in range(N - 1)]
		EDGE = [[] for j in range(N + 1)]
		for (x, y) in XY:
			EDGE[x].append(y)
			EDGE[y].append(x)
		q = collections.deque()
		q.append((0, 1))
		v = set()
		v.add(1)
		cnt = [0] * (N + 1)
		plus_cnt = [0] * (N + 1)
		ans = True
		while q:
			(p, c) = q[-1]
			if EDGE[c]:
				next = EDGE[c].pop()
				if next not in v:
					q.append((c, next))
					v.add(next)
			else:
				q.pop()
				cnt[c] += P[c - 1]
				cnt[p] += cnt[c]
				if (cnt[c] - H[c - 1]) % 2 == 1 or plus_cnt[c] - (cnt[c] - plus_cnt[c]) > H[c - 1] or cnt[c] < H[c - 1]:
					ans = False
					break
				else:
					plus_cnt[p] += cnt[c] - (cnt[c] - H[c - 1]) // 2
		if ans:
			print('YES')
		else:
			print('NO')
main()


import sys
input = sys.stdin.readline
import math
sys.setrecursionlimit(10 ** 6)

class Node:

	def __init__(self, id=None, pop=None, mood=None):
		self.connections = []
		self.pop = pop
		self.mood = mood
		self.id = id
cities = {}

def dfs(root, parent):
	global cities
	if len(root.connections) > 0:
		for edge in root.connections:
			if edge.id != parent:
				dfs(edge, root.id)
		x = root.pop
		subg = 0
		for edge in root.connections:
			if edge.id != parent:
				x += cities[edge.id][0]
				subg += cities[edge.id][1]
		g = (root.mood + x) / 2
		cities[root.id] = [x, g, g - subg]
	else:
		x = root.pop
		g = (root.mood + x) / 2
		cities[root.id] = [x, g, g]

def tree(n, countryNodes):
	global cities
	cities = {}
	for city in range(1, n + 1):
		cities[city] = 0
	dfs(countryNodes[1], -1)
	for (ele, val) in cities.items():
		if val[1] < 0 or math.modf(val[1])[0] != 0 or val[1] > val[0] or (val[2] < 0):
			return 'NO'
	return 'YES'

def solution():
	arr = list(map(lambda x: int(x), input().split()))
	n = arr[0]
	pop = arr[1]
	countryNodes = {}
	cities = list(map(lambda x: int(x), input().split()))
	mood = list(map(lambda x: int(x), input().split()))
	for i in range(len(cities)):
		countryNodes[i + 1] = Node(i + 1, cities[i], mood[i])
	for i in range(n - 1):
		l = list(map(lambda x: int(x), input().split()))
		countryNodes[l[0]].connections.append(countryNodes[l[1]])
		countryNodes[l[1]].connections.append(countryNodes[l[0]])
	print(tree(n, countryNodes))
t = int(input())
for i in range(0, t):
	solution()


from sys import setrecursionlimit
setrecursionlimit(10 ** 9)
import threading
threading.stack_size(67108864)

def dfs1(v):
	global u, used, h, p, ok, d
	if not ok:
		return
	used[v] = True
	hap = 0
	for i in u[v]:
		if not used[i]:
			dfs1(i)
			p[v] += p[i]
			hap += d[i]
	d[v] = (p[v] + h[v]) // 2
	if (p[v] + h[v]) % 2 != 0 or not 0 <= d[v] <= p[v]:
		ok = False
		return
	if d[v] < hap:
		ok = False
		return

def main():
	global u, used, d, p, h, ok
	ans = []
	for _ in range(int(input())):
		(n, m) = map(int, input().split())
		p = list(map(int, input().split()))
		h = list(map(int, input().split()))
		d = [0] * n
		u = []
		ok = True
		for i in range(n):
			u.append([])
		for i in range(n - 1):
			(a, b) = map(lambda z: int(z) - 1, input().split())
			u[a].append(b)
			u[b].append(a)
		used = [0] * n
		dfs1(0)
		if not ok:
			ans.append('NO')
		else:
			ans.append('YES')
	print('\n'.join(ans))
thread = threading.Thread(target=main)
thread.start()
thread.join()


import sys
sys.setrecursionlimit(10 ** 6)

def doDfs(n, p, h, graph):
	visited = [0] * n
	a = [0] * n
	goods = [0] * n
	answ = ['yes']

	def dfs(v):
		visited[v] = 1
		sum_goods = 0
		a[v] = p[v]
		for to in graph[v]:
			if not visited[to]:
				dfs(to)
				a[v] += a[to]
				sum_goods += goods[to]
		goods[v] = (a[v] + h[v]) // 2
		if abs(a[v] + h[v]) % 2 != 0 or sum_goods > goods[v] or goods[v] > a[v]:
			answ[0] = 'no'
	dfs(0)
	print(answ[0])

def solve(n, m, p, h, graph):
	doDfs(n, p, h, graph)
t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	p = [int(j) for j in input().split()]
	h = [int(j) for j in input().split()]
	graph = {}
	for j in range(n - 1):
		(k1, k2) = map(lambda x: int(x) - 1, input().split())
		if graph.get(k1, -1) == -1:
			graph[k1] = []
		if graph.get(k2, -1) == -1:
			graph[k2] = []
		graph[k1].append(k2)
		graph[k2].append(k1)
	if n == 1:
		graph[0] = []
	solve(n, m, p, h, graph)


import math
from sys import setrecursionlimit
setrecursionlimit(10 ** 5 + 100)

def check(v, pr):
	sumy = 0
	pn = p[v]
	for x in g[v]:
		if x == pr:
			continue
		if check(x, v) == 0:
			return 0
		p[v] += p[x]
		sumy += y[x]
	pos = (p[v] + h[v]) // 2
	neg = (p[v] - h[v]) // 2
	y[v] = neg
	if pos + neg != p[v] or pos - neg != h[v] or pos < 0 or (neg < 0) or (pos > p[v]) or (neg > p[v]):
		return 0
	if y[v] <= sumy + pn:
		return 1
	return 0
t = int(input())
while t > 0:
	t -= 1
	global g, y, h, p
	(n, m) = map(int, input().split())
	p = list(map(int, input().split()))
	h = list(map(int, input().split()))
	y = [0] * n
	g = [[] for i in range(n)]
	for i in range(n - 1):
		(a, b) = map(int, input().split())
		a -= 1
		b -= 1
		g[a].append(b)
		g[b].append(a)
	if check(0, -1) == 1:
		print('YES')
	else:
		print('NO')


from collections import defaultdict
import sys
sys.setrecursionlimit(10 ** 5)
t = int(input())

def search(last_index, index, m):
	sum_h = 0
	sum_num = 0
	sum_ruined = 0
	for nxt in ftree[index]:
		if nxt == last_index:
			continue
		(tmp, num, ruined) = search(index, nxt, m)
		if not tmp:
			return (False, -1, -1)
		sum_h += h[nxt]
		sum_num += num
		sum_ruined += ruined
	tmp = sum_num + sum_h
	check_list = [tmp, sum_num - sum_h]
	ruined_num = sum_ruined
	sum_num += p[index]
	tmp = sum_num + h[index]
	check_list.append(tmp)
	check_list.append(sum_num - h[index])
	origin_ruined_num = (sum_num - h[index]) // 2
	if len(ftree[index]) > 1 and origin_ruined_num - p[index] > ruined_num:
		return (False, -1, -1)
	for tmp in check_list:
		if tmp < 0 or tmp > 2 * m or tmp % 2:
			return (False, -1, -1)
	return (True, sum_num, origin_ruined_num)
for _ in range(t):
	(n, m) = map(int, input().split())
	ftree = defaultdict(list)
	p = [0] + list(map(int, input().split()))
	h = [0] + list(map(int, input().split()))
	for _ in range(n - 1):
		(x, y) = map(int, input().split())
		ftree[x].append(y)
		ftree[y].append(x)
	ftree[1].append(-1)
	try:
		(flag, num, _) = search(-1, 1, m)
	except Exception:
		print('NO')
	else:
		res = 'YES' if flag else 'NO'
		print(res)


from sys import stdin

def input():
	return stdin.buffer.readline()
t = int(input())
for _ in range(t):
	(n, m) = list(map(int, input().split()))
	p = list(map(int, input().split()))
	h = list(map(int, input().split()))
	ne = [[] for _ in range(n)]
	q = [1]
	seen = [False] * n
	poped = [False] * n
	cp = [0] * n
	wh = [0] * n
	for i in range(n - 1):
		(a, b) = list(map(int, input().split()))
		ne[a - 1].append(b)
		ne[b - 1].append(a)
	while len(q) > 0:
		a = q[-1]
		seen[a - 1] = True
		flag = False
		p_a = 0
		wh_a = 0
		for n in ne[a - 1]:
			if seen[n - 1] is False:
				flag = True
				q.append(n)
			elif poped[n - 1] is True:
				p_a += cp[n - 1]
				wh_a += wh[n - 1]
		if flag is False:
			a = q.pop()
			poped[a - 1] = True
			cp[a - 1] = p_a + p[a - 1]
			if h[a - 1] > cp[a - 1] or h[a - 1] % 2 != cp[a - 1] % 2:
				print('NO')
				break
			else:
				wh[a - 1] = (cp[a - 1] - h[a - 1]) // 2 + h[a - 1]
				if wh_a > wh[a - 1]:
					print('NO')
					break
				else:
					continue
	else:
		print('YES')


from __future__ import division, print_function
MOD = 998244353
mod = 10 ** 9 + 7

def prepare_factorial():
	fact = [1]
	for i in range(1, 100005):
		fact.append(fact[-1] * i % mod)
	ifact = [0] * 100005
	ifact[100004] = pow(fact[100004], mod - 2, mod)
	for i in range(100004, 0, -1):
		ifact[i - 1] = i * ifact[i] % mod
	return (fact, ifact)
from types import GeneratorType

def bootstrap(f, stack=[]):

	def wrappedfunc(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		else:
			to = f(*args, **kwargs)
			while True:
				if type(to) is GeneratorType:
					stack.append(to)
					to = next(to)
				else:
					stack.pop()
					if not stack:
						break
					to = stack[-1].send(to)
			return to
	return wrappedfunc
from bisect import bisect_left, bisect_right, insort
from math import floor, ceil, sqrt, degrees, atan, pi, log, sin, radians
from heapq import heappop, heapify, heappush
from collections import Counter, defaultdict, deque

def modinv(n, p):
	return pow(n, p - 2, p)

def ncr(n, r, fact, ifact):
	t = fact[n] * (ifact[r] * ifact[n - r]) % mod % mod
	return t

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

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

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

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

def lcm(x, y):
	return x * y // GCD(x, y)

def get_xor(n):
	return [n, 1, n + 1, 0][n % 4]

def fast_expo(a, b):
	res = 1
	while b:
		if b & 1:
			res = res * a
			res %= MOD
			b -= 1
		else:
			a = a * a
			a %= MOD
			b >>= 1
	res %= MOD
	return res

def get_n(P):
	ans = (-1 + sqrt(1 + 8 * P)) // 2
	return ans

def solve():

	@bootstrap
	def dfs(d, s, par, p, h, alt, hm):
		nonlocal pos
		check = 0
		alt[s] = p[s]
		for i in d[s]:
			if i == par:
				continue
			alt[s] += (yield dfs(d, i, s, p, h, alt, hm))
			check += hm[i]
		hm[s] = (alt[s] + h[s]) // 2
		if (alt[s] + h[s]) % 2:
			pos = 0
		if 0 > hm[s] or alt[s] < hm[s]:
			pos = 0
		if check > hm[s]:
			pos = 0
		yield alt[s]
	(n, m) = map(int, input().split())
	pop = [int(i) for i in input().split()]
	happy = [int(i) for i in input().split()]
	d = defaultdict(list)
	for i in range(n - 1):
		(a, b) = map(int, input().split())
		a -= 1
		b -= 1
		d[a].append(b)
		d[b].append(a)
	g = [0 for i in range(n)]
	alt = [0 for i in range(n)]
	pos = 1
	dfs(d, 0, 0, pop, happy, alt, g)
	if pos:
		print('YES')
	else:
		print('NO')

def main():
	T = int(input())
	while T:
		solve()
		T -= 1
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
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
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			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()


from sys import setrecursionlimit as srl
srl(3 * 10 ** 5)

def dfs(v, pa):
	(good, bad) = (0, 0)
	for nex in lis[v]:
		if nex != pa:
			(nans, ng, nb) = dfs(nex, v)
			if not nans:
				return (nans, 0, 0)
			good += ng
			bad += nb
	num = good + bad + p[v]
	if (num - h[v]) % 2 == 0:
		newbad = (num - h[v]) // 2
	else:
		return (False, 0, 0)
	newgood = num - newbad
	if newbad - p[v] > bad or newgood < good or newbad < 0 or (newgood < 0):
		return (False, 0, 0)
	else:
		return (True, newgood, newbad)
for loop in range(int(input())):
	(n, m) = map(int, input().split())
	(p, h) = (list(map(int, input().split())), list(map(int, input().split())))
	lis = [[] for i in range(n)]
	for i in range(n - 1):
		(v, u) = map(int, input().split())
		v -= 1
		u -= 1
		lis[v].append(u)
		lis[u].append(v)
	(ans, good, bad) = dfs(0, 0)
	print('YES') if ans else print('NO')


import sys, collections, bisect, os, io
sys.stdin = io.BytesIO(os.read(0, os.fstat(0).st_size))
input = lambda : sys.stdin.readline()
que = collections.deque
vector = collections.defaultdict
bsearch = bisect.bisect_left
inin = lambda : int(input())
inar = lambda : list(map(int, input().split()))
INF = float('inf')
from types import GeneratorType

def bootstrap(f, stack=[]):

	def wrappedfunc(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		else:
			to = f(*args, **kwargs)
			while True:
				if type(to) is GeneratorType:
					stack.append(to)
					to = next(to)
				else:
					stack.pop()
					if not stack:
						break
					to = stack[-1].send(to)
			return to
	return wrappedfunc
ans = ''

@bootstrap
def dfs(graph, node, par, vis, h, p):
	global ans
	check = 0
	vis[node] = p[node]
	for child in graph[node]:
		if child != par:
			vis[node] += (yield dfs(graph, child, node, vis, h, p))
			check += h[child]
	if (vis[node] + h[node]) % 2:
		ans = 'NO'
	if abs(h[node]) > vis[node]:
		ans = 'NO'
	if check > p[node] + h[node]:
		ans = 'NO'
	yield vis[node]
Testcase = inin()
for Case in range(Testcase):
	ans = 'YES'
	(n, m) = inar()
	qq = que()
	qq.append(n)
	qq.append(m)
	a = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
	idx = bsearch(a, 5)
	p = [0] + inar()
	h = [m + 8] + inar()
	vis = [0 for i in range(n + 1)]
	graph = [[] for i in range(n + 1)]
	for i in range(n - 1):
		(a, b) = inar()
		graph[a].append(b)
		graph[b].append(a)
	dfs(graph, 1, 0, vis, h, p)
	print(ans)


from sys import stdin
import sys, threading
import math
input = stdin.readline

def dfs(current, parent, children, h, p):
	happypeople = 0
	people = p[current - 1]
	happiness = h[current - 1]
	for c in children[current]:
		if c != parent:
			(peoplei, happypeoplei) = dfs(c, current, children, h, p)
			if happypeoplei == -1:
				return (-1, -1)
			happypeople += happypeoplei
			people += peoplei
	if happiness > people or happiness < -people:
		return (-1, -1)
	z = (people - happiness) / 2
	if z != int(z):
		return (-1, -1)
	if people - z < happypeople:
		return (-1, -1)
	return (people, people - z)

def main():
	t = int(input())
	for _ in range(t):
		(n, m) = list(map(int, input().rstrip().split(' ')))
		p = list(map(int, input().rstrip().split(' ')))
		h = list(map(int, input().rstrip().split(' ')))
		children = [[] for i in range(n + 1)]
		for _ in range(n - 1):
			(x, y) = map(int, input().rstrip().split(' '))
			children[x].append(y)
			children[y].append(x)
		(people, happypeople) = dfs(1, -1, children, h, p)
		if happypeople == -1:
			print('NO')
		else:
			print('YES')
sys.setrecursionlimit(100001)
threading.stack_size(512000)
thread = threading.Thread(target=main)
thread.start()


import sys
input = sys.stdin.readline
from collections import deque

class Graph(object):

	def __init__(self, n, d):
		self.n = n
		self.graph = [[] for i in range(n)]
		self.parent = [-1 for i in range(n)]
		self.directed = d

	def addEdge(self, x, y):
		self.graph[x].append(y)
		if not self.directed:
			self.graph[y].append(x)

	def bfs(self, root):
		queue = [root]
		queue = deque(queue)
		vis = [0] * self.n
		while len(queue) != 0:
			element = queue.popleft()
			vis[element] = 1
			for i in self.graph[element]:
				if vis[i] == 0:
					queue.append(i)
					self.parent[i] = element
					vis[i] = 1
			count[element][0] = (passed[element] + h[element]) // 2
			count[element][1] = passed[element] - count[element][0]

	def dfs(self, root, ans):
		stack = [root]
		vis = [0] * self.n
		stack2 = []
		while len(stack) != 0:
			element = stack.pop()
			if vis[element]:
				continue
			vis[element] = 1
			stack2.append(element)
			for i in self.graph[element]:
				if vis[i] == 0:
					self.parent[i] = element
					stack.append(i)
		while len(stack2) != 0:
			element = stack2.pop()
			m = 0
			for i in self.graph[element]:
				if i != self.parent[element]:
					m += ans[i]
			ans[element] = m + p[element]
		return ans

	def shortestpath(self, source, dest):
		self.bfs(source)
		path = [dest]
		while self.parent[path[-1]] != -1:
			path.append(parent[path[-1]])
		return path[::-1]

	def detect_cycle(self):
		indeg = [0] * self.n
		for i in range(self.n):
			for j in self.graph[i]:
				indeg[j] += 1
		q = deque()
		vis = 0
		for i in range(self.n):
			if indeg[i] == 0:
				q.append(i)
		while len(q) != 0:
			e = q.popleft()
			vis += 1
			for i in self.graph[e]:
				indeg[i] -= 1
				if indeg[i] == 0:
					q.append(i)
		if vis != self.n:
			return True
		return False

	def reroot(self, root, ans):
		stack = [root]
		vis = [0] * n
		while len(stack) != 0:
			e = stack[-1]
			if vis[e]:
				stack.pop()
				continue
			vis[e] = 1
			for i in graph[e]:
				if not vis[e]:
					stack.append(i)
			if self.parent[e] == -1:
				continue

	def check(self):
		q = [0]
		q = deque(q)
		vis = [0] * n
		while q:
			e = q.popleft()
			vis[e] = 1
			c = 0
			for i in self.graph[e]:
				if not vis[i]:
					q.append(i)
					c += count[i][1]
			if c < count[e][1] - p[e]:
				return False
			if (passed[e] + h[e]) % 2 or count[e][0] < 0 or count[e][1] < 0:
				return False
		return True
for nt in range(int(input())):
	(n, m) = map(int, input().split())
	p = list(map(int, input().split()))
	h = list(map(int, input().split()))
	g = Graph(n, False)
	for i in range(n - 1):
		(x, y) = map(int, input().split())
		g.addEdge(x - 1, y - 1)
	passed = [0] * n
	count = [[0, 0] for i in range(n)]
	passed = g.dfs(0, passed)
	g.bfs(0)
	if g.check():
		print('YES')
	else:
		print('NO')


import sys
input = sys.stdin.readline
t = int(input())
for tests in range(t):
	(n, m) = map(int, input().split())
	P = [0] + list(map(int, input().split()))
	H = [0] + list(map(int, input().split()))
	E = [[] for i in range(n + 1)]
	for i in range(n - 1):
		(x, y) = map(int, input().split())
		E[x].append(y)
		E[y].append(x)
	TOP_SORT = []
	Q = [1]
	USE = [0] * (n + 1)
	PARENT = [0] * (n + 1)
	while Q:
		x = Q.pop()
		USE[x] = 1
		TOP_SORT.append(x)
		for to in E[x]:
			if USE[to] == 0:
				PARENT[to] = x
				Q.append(to)
	for x in TOP_SORT[1:][::-1]:
		P[PARENT[x]] += P[x]
	HP = [0] * (n + 1)
	for i in range(1, n + 1):
		HP[i] = (P[i] + H[i]) // 2
		if HP[i] != (P[i] + H[i]) / 2 or HP[i] < 0 or HP[i] > P[i]:
			print('NO')
			break
	else:
		for i in range(1, n + 1):
			if i != 1 and P[i] > P[PARENT[i]]:
				print('NO')
				break
			SUM = 0
			for to in E[i]:
				if to == PARENT[i]:
					continue
				SUM += HP[to]
			if SUM > HP[i]:
				print('NO')
				break
		else:
			print('YES')


import sys
sys.setrecursionlimit(int(100000.0) + 7)
ip = sys.stdin.readline
for _ in range(int(ip())):
	(n, m) = map(int, ip().split())
	p = list(map(int, ip().split()))
	h = list(map(int, ip().split()))
	graph = [[] for _ in range(n)]
	a = [0] * n
	g = [0] * n
	for _ in range(n - 1):
		(x, y) = map(int, ip().split())
		x -= 1
		y -= 1
		graph[x].append(y)
		graph[y].append(x)

	def dfs(node, ancestor):
		a[node] = p[node]
		sg = 0
		for destination in graph[node]:
			if destination == ancestor:
				continue
			dfs(destination, node)
			a[node] += a[destination]
			sg += g[destination]
		if (a[node] + h[node]) % 2:
			flag[0] = False
		g[node] = a[node] + h[node] >> 1
		if not 0 <= g[node] <= a[node]:
			flag[0] = False
		if not sg <= g[node]:
			flag[0] = False
	flag = [True]
	dfs(0, -1)
	print('YES' if flag[0] else 'NO')


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__
sys.setrecursionlimit(300000)

def gift():

	def dfs(v, pa):
		good = 0
		bad = 0
		for nex in dic[v]:
			if nex != pa:
				(nans, ng, nb) = dfs(nex, v)
				if not nans:
					return (nans, 0, 0)
				good += ng
				bad += nb
		num = good + bad + p[v]
		if (num - h[v]) % 2 == 0:
			newbad = (num - h[v]) // 2
		else:
			return (False, 0, 0)
		newgood = num - newbad
		if newbad - p[v] > bad or newgood < good or newbad < 0 or (newgood < 0):
			return (False, 0, 0)
		else:
			return (True, newgood, newbad)
	for _ in range(t):
		(city, people) = list(map(int, input().split()))
		p = list(map(int, input().split()))
		h = list(map(int, input().split()))
		dic = [[] for i in range(city)]
		for i in range(city - 1):
			(s, e) = list(map(int, input().split()))
			dic[s - 1].append(e - 1)
			dic[e - 1].append(s - 1)
		(ans, good, bad) = dfs(0, 0)
		yield ('YES' if ans else 'NO')
t = int(input())
ans = gift()
print(*ans, sep='\n')


import sys
input = sys.stdin.buffer.readline
poss = True

def dfs(graph, node, par, p, h, totpop, g):
	global poss
	totpop[node] = p[node]
	tothap = 0
	for u in graph[node]:
		if u != par:
			dfs(graph, u, node, p, h, totpop, g)
			totpop[node] += totpop[u]
			tothap += g[u]
	g[node] = (totpop[node] + h[node]) // 2
	if abs(h[node]) & 1 != totpop[node] & 1:
		poss = False
	if tothap > g[node]:
		poss = False
	if totpop[node] < 0 or totpop[node] < g[node]:
		poss = False
for _ in range(int(input())):
	poss = True
	(n, m) = [int(c) for c in input().split()]
	p = [0] + [int(c) for c in input().split()]
	h = [0] + [int(c) for c in input().split()]
	graph = {i: [] for i in range(1, n + 1)}
	for i in range(n - 1):
		(x, y) = [int(c) for c in input().split()]
		graph[x].append(y)
		graph[y].append(x)
	totpop = [0 for i in range(n + 1)]
	g = [0 for i in range(n + 1)]
	try:
		dfs(graph, 1, 1, p, h, totpop, g)
	except:
		pass
	if poss == True:
		print('YES')
	else:
		print('NO')


import sys
import math
from collections import defaultdict, Counter, deque
sys.setrecursionlimit(10 ** 5)
input = sys.stdin.readline

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

def add(a, b):
	l[a].append(b)
	l[b].append(a)

def find(u, v):
	global flag
	a[u] = p[u - 1]
	sumg = 0
	for j in l[u]:
		if j != v:
			find(j, u)
			if flag == 1:
				return
			a[u] += a[j]
			sumg += g[j]
	if (a[u] + h[u - 1]) % 2 != 0:
		flag = 1
	g[u] = (a[u] + h[u - 1]) // 2
	if g[u] < 0 or g[u] > a[u]:
		flag = 1
	if sumg > g[u]:
		flag = 1
t = int(input())
for i in range(t):
	l = defaultdict(list)
	(n, m) = map(int, input().split())
	p = list(map(int, input().split()))
	h = list(map(int, input().split()))
	for j in range(n - 1):
		(x, y) = map(int, input().split())
		add(x, y)
	g = [0] * (n + 1)
	a = [0] * (n + 1)
	flag = 0
	find(1, 0)
	if flag == 0:
		print('YES')
	else:
		print('NO')


import sys
import math, bisect
sys.setrecursionlimit(10 ** 5)
from itertools import groupby, accumulate
from heapq import heapify, heappop, heappush
from collections import deque, Counter, defaultdict
I = lambda : int(sys.stdin.readline())
neo = lambda : map(int, sys.stdin.readline().split())
Neo = lambda : list(map(int, sys.stdin.readline().split()))
for _ in range(I()):
	(n, m) = neo()
	Ans = 'YES'
	P = Neo()
	H = Neo()
	G = defaultdict(list)
	for i in range(n - 1):
		(x, y) = neo()
		x -= 1
		y -= 1
		G[x] += [y]
		G[y] += [x]
	(A, B) = ([0] * n, [0] * n)

	def dfs(v, ancestor):
		global Ans
		A[v] = P[v]
		tot = 0
		for i in G[v]:
			if i != ancestor:
				dfs(i, v)
				tot += B[i]
				A[v] += A[i]
		if (A[v] + H[v]) % 2:
			Ans = 'NO'
		B[v] = (A[v] + H[v]) // 2
		if 0 > (A[v] + H[v]) // 2 or (A[v] + H[v]) // 2 > A[v]:
			Ans = 'NO'
		if tot > B[v]:
			Ans = 'NO'
	dfs(0, -1)
	print(Ans)


import sys
sys.setrecursionlimit(10 ** 6)

def doDfs(g, n, p, h):
	a = [0] * n
	goods = [0] * n
	visited = [0] * n
	answ = ['yes']

	def dfs(u):
		sum_g = 0
		visited[u] = 1
		a[u] = p[u]
		for to in g[u]:
			if not visited[to]:
				dfs(to)
				sum_g += goods[to]
				a[u] += a[to]
		goods[u] = (a[u] + h[u]) // 2
		if (a[u] + h[u]) % 2 == 0:
			pass
		else:
			answ[0] = 'no'
		goods[u] = (a[u] + h[u]) // 2
		if goods[u] >= 0 and goods[u] <= a[u]:
			pass
		else:
			answ[0] = 'no'
		if sum_g <= goods[u]:
			pass
		else:
			answ[0] = 'no'
	dfs(0)
	print(answ[0])

def solve(n, m, p, h, g):
	doDfs(g, n, p, h)
t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	p = [int(j) for j in input().split()]
	h = [int(j) for j in input().split()]
	g = {}
	for j in range(n - 1):
		(k1, k2) = map(lambda x: int(x) - 1, input().split())
		if g.get(k1, -1) == -1:
			g[k1] = []
		if g.get(k2, -1) == -1:
			g[k2] = []
		g[k1].append(k2)
		g[k2].append(k1)
	if n == 1:
		g[0] = []
	solve(n, m, p, h, g)


import math
import threading, sys

def main():
	m = int(input())
	for l in range(m):
		(n, m) = map(int, input().split())
		p = list(map(int, input().split()))
		h = list(map(int, input().split()))
		di = {}
		for _ in range(n - 1):
			(x, y) = map(int, input().split())
			if x == y:
				continue
			if x - 1 in di:
				di[x - 1].add(y - 1)
			else:
				di[x - 1] = {y - 1}
			if y - 1 in di:
				di[y - 1].add(x - 1)
			else:
				di[y - 1] = {x - 1}

		def dfs(k, pa):
			(good, bad) = (0, 0)
			if k in di:
				for i in di[k]:
					if i == pa:
						continue
					(g, b) = dfs(i, k)
					if g <= -1:
						return (-1, -1)
					good += g
					bad += b
			g1 = good
			g2 = bad
			t = g1 + g2 + p[k]
			good = int((h[k] + t) / 2)
			bad = t - good
			if bad > g2 + p[k] or abs(h[k]) > t or (h[k] + t) % 2 != 0:
				return (-1, -1)
			return (good, bad)
		(gf, bf) = dfs(0, -1)
		if gf == -1 or gf + bf > m:
			print('NO')
		else:
			print('YES')
sys.setrecursionlimit(1000000)
threading.stack_size(1024000)
thread = threading.Thread(target=main)
thread.start()


import sys
input = sys.stdin.readline

def topological_sort(tree: list, root) -> list:
	n = len(tree)
	visited = [False] * n
	visited[root] = True
	tp_sorted = [root]
	stack = [root]
	while stack:
		v = stack.pop()
		for nxt_v in tree[v]:
			if visited[nxt_v]:
				continue
			visited[nxt_v] = True
			stack.append(nxt_v)
			tp_sorted.append(nxt_v)
	return tp_sorted

def get_par(tree: list, root: int) -> list:
	n = len(tree)
	visited = [False] * n
	visited[root] = True
	par = [-1] * n
	stack = [root]
	while stack:
		v = stack.pop()
		for nxt_v in tree[v]:
			if visited[nxt_v]:
				continue
			visited[nxt_v] = True
			stack.append(nxt_v)
			par[nxt_v] = v
	return par
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	p = list(map(int, input().split()))
	h = list(map(int, input().split()))
	edges = [list(map(int, input().split())) for i in range(n - 1)]
	tree = [[] for i in range(n)]
	for (a, b) in edges:
		a -= 1
		b -= 1
		tree[a].append(b)
		tree[b].append(a)
	root = 0
	tp_sort = topological_sort(tree, root)
	par = get_par(tree, root)
	cnts = [[0, 0] for i in range(n)]
	flag = True
	for v in tp_sort[::-1]:
		(good, bad) = (0, 0)
		for nxt_v in tree[v]:
			if nxt_v == par[v]:
				continue
			else:
				good += cnts[nxt_v][0]
				bad += cnts[nxt_v][1]
		sum_p = good + bad + p[v]
		if (sum_p + h[v]) % 2 != 0:
			flag = False
			break
		g = (sum_p + h[v]) // 2
		b = (sum_p - h[v]) // 2
		inc_g = g - good
		if 0 <= inc_g <= p[v] + bad:
			cnts[v] = (g, b)
			continue
		else:
			flag = False
			break
	if flag:
		print('YES')
	else:
		print('NO')


import bisect
import functools
import heapq
import os
import random
import sys
import threading
from collections import deque
import io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
TC = int(input())
P = []
H = []
G = []
from types import GeneratorType

def bootstrap(f, stack=[]):

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

@bootstrap
def validate(x, p):
	hc = 0
	pc = 0
	for c in G[x]:
		if c != p:
			(ht, ct) = (yield validate(c, x))
			pc += ct
			if ht < 0:
				yield (ht, 0)
			else:
				hc += ht
	h2 = P[x] + pc + H[x]
	if h2 % 2 != 0 or h2 < 0 or h2 > 2 * (P[x] + pc) or (h2 < 2 * hc):
		yield (-1, 0)
	yield (h2 // 2, P[x] + pc)
for tc in range(TC):
	(N, M) = map(int, input().split())
	P = list(map(int, input().split()))
	H = list(map(int, input().split()))
	G = [[] for i in range(N)]
	for i in range(N - 1):
		(a, b) = map(int, input().split())
		G[a - 1].append(b - 1)
		G[b - 1].append(a - 1)
	if validate(0, 0)[0] < 0:
		print('No')
	else:
		print('Yes')


from collections import defaultdict as dd, deque as dq
import sys
input = sys.stdin.readline
t = int(input())
while t:
	(n, m) = map(int, input().split())
	d = dd(list)
	ind = [0] * (n + 1)
	vis = [0] * (n + 1)
	popu = list(map(int, input().split()))
	mood = list(map(int, input().split()))
	for i in range(n - 1):
		(u, v) = map(int, input().split())
		d[u].append(v)
		d[v].append(u)
		ind[u] += 1
		ind[v] += 1
	q = dq([])
	for i in range(n, 1, -1):
		if ind[i] == 1 or ind[i] == 0:
			q.append(i)
	par = [0] * (n + 1)
	qq = dq([(1, 0)])
	while qq:
		(a, pa) = qq.pop()
		par[a] = pa
		for i in d[a]:
			if i != pa:
				qq.appendleft((i, a))
	if len(q) == 0:
		q.append(1)
	order = []
	count = dd(int)
	lol = 0
	while q:
		a = q.pop()
		vis[a] = 1
		p = popu[a - 1]
		h = mood[a - 1]
		g = 0
		b = 0
		for j in d[a]:
			if j != par[a]:
				p += popu[j - 1]
				g += count[j]
		go = (p + h) // 2
		ba = (p - h) // 2
		count[a] = go
		if go < g or go < 0 or ba < 0 or (go + ba != p):
			lol = 1
			break
		popu[a - 1] = p
		ind[par[a]] -= 1
		if ind[par[a]] == 1 and par[a] != 1:
			q.appendleft(par[a])
		elif par[a] == 1 and ind[par[a]] == 0:
			q.append(1)
	if lol:
		print('NO')
	else:
		print('YES')
	t -= 1


import math
import heapq, bisect
import sys
from collections import deque, defaultdict
from fractions import Fraction
import sys
import threading
from collections import defaultdict
threading.stack_size(10 ** 8)
mod = 10 ** 9 + 7
mod1 = 998244353
import os
import sys
from io import BytesIO, IOBase
sys.setrecursionlimit(300000)
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')

class TreeNode:

	def __init__(self, k, v):
		self.key = k
		self.value = v
		self.left = None
		self.right = None
		self.parent = None
		self.height = 1
		self.num_left = 1
		self.num_total = 1

class AvlTree:

	def __init__(self):
		self._tree = None

	def add(self, k, v):
		if not self._tree:
			self._tree = TreeNode(k, v)
			return
		node = self._add(k, v)
		if node:
			self._rebalance(node)

	def _add(self, k, v):
		node = self._tree
		while node:
			if k < node.key:
				if node.left:
					node = node.left
				else:
					node.left = TreeNode(k, v)
					node.left.parent = node
					return node.left
			elif node.key < k:
				if node.right:
					node = node.right
				else:
					node.right = TreeNode(k, v)
					node.right.parent = node
					return node.right
			else:
				node.value = v
				return

	@staticmethod
	def get_height(x):
		return x.height if x else 0

	@staticmethod
	def get_num_total(x):
		return x.num_total if x else 0

	def _rebalance(self, node):
		n = node
		while n:
			lh = self.get_height(n.left)
			rh = self.get_height(n.right)
			n.height = max(lh, rh) + 1
			balance_factor = lh - rh
			n.num_total = 1 + self.get_num_total(n.left) + self.get_num_total(n.right)
			n.num_left = 1 + self.get_num_total(n.left)
			if balance_factor > 1:
				if self.get_height(n.left.left) < self.get_height(n.left.right):
					self._rotate_left(n.left)
				self._rotate_right(n)
			elif balance_factor < -1:
				if self.get_height(n.right.right) < self.get_height(n.right.left):
					self._rotate_right(n.right)
				self._rotate_left(n)
			else:
				n = n.parent

	def _remove_one(self, node):
		replacement = node.left or node.right
		if node.parent:
			if AvlTree._is_left(node):
				node.parent.left = replacement
			else:
				node.parent.right = replacement
			replacement.parent = node.parent
			node.parent = None
		else:
			self._tree = replacement
			replacement.parent = None
		node.left = None
		node.right = None
		node.parent = None
		self._rebalance(replacement)

	def _remove_leaf(self, node):
		if node.parent:
			if AvlTree._is_left(node):
				node.parent.left = None
			else:
				node.parent.right = None
			self._rebalance(node.parent)
		else:
			self._tree = None
		node.parent = None
		node.left = None
		node.right = None

	def remove(self, k):
		node = self._get_node(k)
		if not node:
			return
		if AvlTree._is_leaf(node):
			self._remove_leaf(node)
			return
		if node.left and node.right:
			nxt = AvlTree._get_next(node)
			node.key = nxt.key
			node.value = nxt.value
			if self._is_leaf(nxt):
				self._remove_leaf(nxt)
			else:
				self._remove_one(nxt)
			self._rebalance(node)
		else:
			self._remove_one(node)

	def get(self, k):
		node = self._get_node(k)
		return node.value if node else -1

	def _get_node(self, k):
		if not self._tree:
			return None
		node = self._tree
		while node:
			if k < node.key:
				node = node.left
			elif node.key < k:
				node = node.right
			else:
				return node
		return None

	def get_at(self, pos):
		x = pos + 1
		node = self._tree
		while node:
			if x < node.num_left:
				node = node.left
			elif node.num_left < x:
				x -= node.num_left
				node = node.right
			else:
				return (node.key, node.value)
		raise IndexError('Out of ranges')

	@staticmethod
	def _is_left(node):
		return node.parent.left and node.parent.left == node

	@staticmethod
	def _is_leaf(node):
		return node.left is None and node.right is None

	def _rotate_right(self, node):
		if not node.parent:
			self._tree = node.left
			node.left.parent = None
		elif AvlTree._is_left(node):
			node.parent.left = node.left
			node.left.parent = node.parent
		else:
			node.parent.right = node.left
			node.left.parent = node.parent
		bk = node.left.right
		node.left.right = node
		node.parent = node.left
		node.left = bk
		if bk:
			bk.parent = node
		node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1
		node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)
		node.num_left = 1 + self.get_num_total(node.left)

	def _rotate_left(self, node):
		if not node.parent:
			self._tree = node.right
			node.right.parent = None
		elif AvlTree._is_left(node):
			node.parent.left = node.right
			node.right.parent = node.parent
		else:
			node.parent.right = node.right
			node.right.parent = node.parent
		bk = node.right.left
		node.right.left = node
		node.parent = node.right
		node.right = bk
		if bk:
			bk.parent = node
		node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1
		node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)
		node.num_left = 1 + self.get_num_total(node.left)

	@staticmethod
	def _get_next(node):
		if not node.right:
			return node.parent
		n = node.right
		while n.left:
			n = n.left
		return n

class SegmentTree1:

	def __init__(self, data, default='z', func=lambda a, b: min(a, b)):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class SegmentTree:

	def __init__(self, data, default=0, func=lambda a, b: a + b):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class Factorial:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorials = [1, 1]
		self.invModulos = [0, 1]
		self.invFactorial_ = [1, 1]

	def calc(self, n):
		if n <= -1:
			print('Invalid argument to calculate n!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.factorials):
			return self.factorials[n]
		nextArr = [0] * (n + 1 - len(self.factorials))
		initialI = len(self.factorials)
		prev = self.factorials[-1]
		m = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * i % m
		self.factorials += nextArr
		return self.factorials[n]

	def inv(self, n):
		if n <= -1:
			print('Invalid argument to calculate n^(-1)')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		p = self.MOD
		pi = n % p
		if pi < len(self.invModulos):
			return self.invModulos[pi]
		nextArr = [0] * (n + 1 - len(self.invModulos))
		initialI = len(self.invModulos)
		for i in range(initialI, min(p, n + 1)):
			next = -self.invModulos[p % i] * (p // i) % p
			self.invModulos.append(next)
		return self.invModulos[pi]

	def invFactorial(self, n):
		if n <= -1:
			print('Invalid argument to calculate (n^(-1))!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.invFactorial_):
			return self.invFactorial_[n]
		self.inv(n)
		nextArr = [0] * (n + 1 - len(self.invFactorial_))
		initialI = len(self.invFactorial_)
		prev = self.invFactorial_[-1]
		p = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * self.invModulos[i % p] % p
		self.invFactorial_ += nextArr
		return self.invFactorial_[n]

class Combination:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorial = Factorial(MOD)

	def ncr(self, n, k):
		if k < 0 or n < k:
			return 0
		k = min(k, n - k)
		f = self.factorial
		return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD

def powm(a, n, m):
	if a == 1 or n == 0:
		return 1
	if n % 2 == 0:
		s = powm(a, n // 2, m)
		return s * s % m
	else:
		return a * powm(a, n - 1, m) % m

def sort_list(list1, list2):
	zipped_pairs = zip(list2, list1)
	z = [x for (_, x) in sorted(zipped_pairs)]
	return z

def product(l):
	por = 1
	for i in range(len(l)):
		por *= l[i]
	return por

def binarySearchCount(arr, n, key):
	left = 0
	right = n - 1
	count = 0
	while left <= right:
		mid = int((right + left) / 2)
		if arr[mid] < key:
			count = mid + 1
			left = mid + 1
		else:
			right = mid - 1
	return count

def countdig(n):
	c = 0
	while n > 0:
		n //= 10
		c += 1
	return c

def binary(x, length):
	y = bin(x)[2:]
	return y if len(y) >= length else '0' * (length - len(y)) + y

def countGreater(arr, n, k):
	l = 0
	r = n - 1
	leftGreater = n
	while l <= r:
		m = int(l + (r - l) / 2)
		if arr[m] >= k:
			leftGreater = m
			r = m - 1
		else:
			l = m + 1
	return n - leftGreater

def main():
	for ik in range(int(input())):
		(n, m) = map(int, input().split())
		graph = defaultdict(list)
		visited = [False] * n
		visited1 = [False] * n
		pas = [0] * n
		g = [0] * n
		f = 0

		def DFS(v):
			visited[v] = True
			r = 0
			for i in graph[v]:
				if visited[i] == False:
					r += DFS(i)
			pas[v] = r + l[v]
			return r + l[v]

		def DFS1(v):
			visited1[v] = True
			r = 0
			for i in graph[v]:
				if visited1[i] == False:
					e = DFS1(i)
					r += e
					if e == -999999999999:
						return -999999999999
			if g[v] >= r:
				return g[v]
			else:
				return -999999999999
		l = list(map(int, input().split()))
		h = list(map(int, input().split()))
		for i in range(n - 1):
			(a, b) = map(int, input().split())
			graph[a - 1].append(b - 1)
			graph[b - 1].append(a - 1)
		DFS(0)
		for i in range(n):
			g[i] = pas[i] + h[i]
			if g[i] % 2 != 0:
				print('NO')
				f = 1
				break
			else:
				g[i] //= 2
				if g[i] < 0 or g[i] > pas[i]:
					print('NO')
					f = 1
					break
		if f == 1:
			continue
		g1 = DFS1(0)
		if g1 == -999999999999:
			print('NO')
		else:
			print('YES')
t = threading.Thread(target=main)
t.start()
t.join()


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

def bootstrap(f, stack=[]):

	def wrappedfunc(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		else:
			to = f(*args, **kwargs)
			while True:
				if type(to) is GeneratorType:
					stack.append(to)
					to = next(to)
				else:
					stack.pop()
					if not stack:
						break
					to = stack[-1].send(to)
			return to
	return wrappedfunc
from collections import defaultdict, deque

def solve():
	(n, m) = map(int, input().split())
	p = list(map(int, input().split()))
	h = list(map(int, input().split()))
	tree = defaultdict(list)
	for i in range(n - 1):
		(u, v) = map(int, input().split())
		tree[u].append(v)
		tree[v].append(u)
	possible = True
	cip = [0] * (n + 1)
	stack = [1]
	seen = {}
	seen_twice = {}
	while stack:
		node = stack[-1]
		if node in seen:
			seen_twice[node] = 1
			s = 0
			hs = 0
			leaf = True
			for child in tree[node]:
				s += cip[child]
				if child in seen_twice:
					hs += h[child - 1]
					leaf = False
			cip[node] = s + p[node - 1]
			if abs(h[node - 1]) > cip[node] or cip[node] % 2 != h[node - 1] % 2 or ((hs - p[node - 1] > h[node - 1] or (hs - p[node - 1]) % 2 != h[node - 1] % 2) and leaf == False):
				possible = False
			stack.pop()
			continue
		seen[node] = 1
		for child in tree[node]:
			if child not in seen:
				stack.append(child)
	if possible == True:
		print('YES')
	else:
		print('NO')

def main():
	for _ in range(int(input())):
		solve()
main()


import os
import sys
from io import BytesIO, IOBase
import math

def dfsVisited(G, node, nodeInfo, V, P):
	V.add(node)
	ans = 0
	for v in G[node]:
		if v not in V:
			ans += dfsVisited(G, v, nodeInfo, V, P)
	ans += P[node - 1]
	nodeInfo[node - 1][0] = ans
	return ans

def dfsCheckBecameHappy(G, node, nodeInfo, V):
	V.add(node)
	childUnhappy = 0
	childHappy = 0
	for v in G[node]:
		if v not in V:
			childHappy += nodeInfo[v - 1][1]
	if childHappy > nodeInfo[node - 1][1]:
		return False
	ans = True
	for v in G[node]:
		if v not in V:
			ans = ans and dfsCheckBecameHappy(G, v, nodeInfo, V)
	return ans

def main():
	t = int(input())
	for _ in range(t):
		(n, m) = map(int, input().split())
		P = list(map(int, input().split()))
		H = list(map(int, input().split()))
		root = 1
		graph = dict()
		nodeInfo = [[-1] * 3 for i in range(n)]
		for i in range(1, n + 1):
			graph[i] = list()
		for _ in range(n - 1):
			(u, v) = map(int, input().split())
			graph[u].append(v)
			graph[v].append(u)
		visited = set()
		_ = dfsVisited(graph, 1, nodeInfo, visited, P)
		okay = True
		for i in range(n):
			happy = (nodeInfo[i][0] + H[i]) / 2
			if math.floor(happy) != math.ceil(happy):
				okay = not okay
				break
			unhappy = nodeInfo[i][0] - happy
			if happy < 0 or unhappy < 0:
				okay = not okay
				break
			nodeInfo[i][1] = int(happy)
			nodeInfo[i][2] = int(unhappy)
		if not okay:
			print('NO')
			continue
		visited = set()
		if dfsCheckBecameHappy(graph, 1, nodeInfo, visited):
			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 = lambda s: self.buffer.write(s.encode()) if self.writable else None

	def read(self):
		if self.buffer.tell():
			return self.buffer.read().decode('ascii')
		return os.read(self._fd, os.fstat(self._fd).st_size).decode('ascii')

	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().decode('ascii')

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

def print(*args, sep=' ', end='\n', file=sys.stdout, flush=False):
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(end)
	if flush:
		file.flush()
(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
sys.setrecursionlimit(int(10000000.0))
main()


import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log2, ceil
from collections import defaultdict
from bisect import bisect_left as bl, bisect_right as br
from collections import Counter
from collections import deque
ip = lambda : int(stdin.readline())
inp = lambda : map(int, stdin.readline().split())
ips = lambda : stdin.readline().rstrip()

def addEdge(a, b):
	graph[a].append(b)
	graph[b].append(a)

def Bfs(src):
	q = deque([])
	q.append(src)
	visited[src] = True
	dist[src] = 0
	while q:
		node = q.popleft()
		for neighbour in graph[node]:
			if not visited[neighbour]:
				flag = False
				q.append(neighbour)
				visited[neighbour] = True
				dist[neighbour] = dist[node] + 1
				parent[neighbour] = node
				level[dist[neighbour]].append(neighbour)
t = ip()
for _ in range(t):
	r = []
	(n, m) = inp()
	p = list(inp())
	h = list(inp())
	graph = [[] for i in range(n)]
	dist = [0] * n
	visited = [False] * n
	parent = [-1] * n
	g = [0] * n
	level = defaultdict(list)
	leaf = [False] * n
	for i in range(n - 1):
		(a, b) = inp()
		r.append('{} {}'.format(a, b))
		addEdge(a - 1, b - 1)
	Bfs(0)
	ch = sorted(list(level.keys()), reverse=True)
	a = [0] * n
	a[0] += p[0]
	for i in ch:
		for j in level[i]:
			a[j] += p[j]
			par = parent[j]
			a[par] += a[j]
	flag = False
	for i in range(n):
		if a[i] + h[i] & 1 == 1:
			flag = True
			break
		else:
			g[i] = (a[i] + h[i]) // 2
			if g[i] >= 0 and g[i] <= a[i]:
				pass
			else:
				flag = True
				break
	if flag:
		print('NO')
	else:
		dp = [0] * n
		for i in ch:
			for j in level[i]:
				par = parent[j]
				dp[par] += g[j]
		flag = True
		for i in range(n):
			if dp[i] <= g[i]:
				pass
			else:
				flag = False
				break
		if flag:
			print('YES')
		else:
			print('NO')


import sys
sys.setrecursionlimit(100000)
for _ in range(int(input())):
	(n, p) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	g = [[] for i in range(n + 1)]
	for i in range(n - 1):
		(u, v) = map(int, input().split())
		g[u].append(v)
		g[v].append(u)
	vis = set()

	def dfs(root):
		count = 0
		h = 0
		for i in g[root]:
			if i not in vis:
				vis.add(i)
				(temp, htemp) = dfs(i)
				count += temp
				h += htemp
		count += a[root - 1]
		happy = count + b[root - 1]
		if happy % 2:
			ans[0] = 'NO'
		happy //= 2
		if happy < 0 or happy > count:
			ans[0] = 'NO'
		elif h > happy:
			ans[0] = 'NO'
		return (count, happy)
	ans = ['YES']
	vis.add(1)
	dfs(1)
	print(ans[0])


import sys
sys.setrecursionlimit(3 * 10 ** 5)

def getNextLine():
	return list(map(lambda x: int(x), input().split()))

def getAdjListFromEdges(listLength, noOfEdges):
	adjList = [[] for i in range(0, listLength)]
	for i in range(0, noOfEdges):
		line = getNextLine()
		u = line[0]
		v = line[1]
		adjList[u].append(v)
		adjList[v].append(u)
	return adjList

class Solution:

	def __init__(self):
		line1: list = getNextLine()
		self.n = line1[0]
		self.m = line1[1]
		self.p = [0]
		self.h = [0]
		self.p.extend(getNextLine())
		self.h.extend(getNextLine())
		self.adjList = getAdjListFromEdges(self.n + 1, self.n - 1)
		self.visited = [False for i in range(0, self.n + 1)]
		self.fHappy = [0 for i in range(0, self.n + 1)]
		self.fSad = [0 for i in range(0, self.n + 1)]
		self.isPossible = True

	def dfs(self, vertex):
		if self.isPossible == False:
			return
		self.visited[vertex] = True
		h_ = 0
		s_ = 0
		for adjVertex in self.adjList[vertex]:
			if self.visited[adjVertex] == False:
				self.dfs(adjVertex)
				h_ += self.fHappy[adjVertex]
				s_ += self.fSad[adjVertex]
		T = h_ + s_ + self.p[vertex]
		if (T + self.h[vertex]) % 2 == 0:
			self.fHappy[vertex] = int((T + self.h[vertex]) / 2)
		else:
			self.isPossible = False
			return
		if (T - self.h[vertex]) % 2 == 0:
			self.fSad[vertex] = int((T - self.h[vertex]) / 2)
		else:
			self.isPossible = False
			return
		if h_ > self.fHappy[vertex] or self.fHappy[vertex] + self.fSad[vertex] != T or self.fHappy[vertex] < 0 or (self.fSad[vertex] < 0):
			self.isPossible = False

	def solve(self):
		self.dfs(1)
		if self.isPossible == True:
			print('YES')
		else:
			print('NO')
t = int(input())
for i in range(t):
	s = Solution()
	s.solve()


from collections import defaultdict
import math
import sys
input = sys.stdin.readline
t = int(input())
for ii in range(t):
	(n, m) = map(int, input().split())
	p = [int(i) for i in input().split() if i != '\n']
	h = [int(i) for i in input().split() if i != '\n']
	graph = defaultdict(list)
	childcount = [0] * (n + 1)
	for i in range(n - 1):
		(x, y) = map(int, input().split())
		graph[x].append(y)
		graph[y].append(x)
	OBSERVE = 0
	CHECK = 1
	stack = [(OBSERVE, 1, 0)]
	badcount = [0] * (n + 1)
	goodcount = [0] * (n + 1)
	badcounte = [0] * (n + 1)
	goodcounte = [0] * (n + 1)
	net = [0] * (n + 1)
	hula = [0] * n
	while len(stack):
		(state, vertex, parent) = stack.pop()
		if state == OBSERVE:
			stack.append((CHECK, vertex, parent))
			childcount[vertex] = p[vertex - 1]
			for child in graph[vertex]:
				if child != parent:
					stack.append((OBSERVE, child, vertex))
		else:
			pq = 0
			for child in graph[vertex]:
				if child != parent:
					childcount[vertex] += childcount[child]
					pq += h[child - 1]
			if h[vertex - 1] < pq - p[vertex - 1]:
				print('NO')
				break
			badcount[vertex] = (childcount[vertex] - h[vertex - 1]) / 2
			goodcount[vertex] = childcount[vertex] - badcount[vertex]
			if badcount[vertex] < 0 or goodcount[vertex] < 0 or badcount[vertex] // 1 != badcount[vertex]:
				print('NO')
				break
	else:
		print('YES')


import sys
from array import array
import typing as Tp

def input():
	return sys.stdin.buffer.readline().decode('utf-8')

def bfs(adj, peoples):
	stack = [0]
	order = []
	parent = [-1] * len(adj)
	subt = peoples[:]
	while stack:
		v = stack.pop()
		order.append(v)
		for dest in adj[v]:
			if parent[v] == dest:
				continue
			parent[dest] = v
			stack.append(dest)
	for v in reversed(order):
		if v != 0:
			subt[parent[v]] += subt[v]
	return (order, subt, parent)

def main():
	t = int(input())
	ans = ['NO'] * t
	for ti in range(t):
		(n, m) = map(int, input().split())
		p = list(map(int, input().split()))
		h = list(map(int, input().split()))
		adj = [[] for _ in range(n)]
		for (u, v) in (map(int, input().split()) for _ in range(n - 1)):
			adj[u - 1].append(v - 1)
			adj[v - 1].append(u - 1)
		(order, subt, par) = bfs(adj, p)
		if any((abs(h[i]) > subt[i] or subt[i] - h[i] & 1 for i in range(n))):
			continue
		for v in order:
			v_bad = subt[v] - h[v] >> 1
			child_bad = 0
			for dest in adj[v]:
				if dest == par[v]:
					continue
				child_bad += subt[dest] - h[dest] >> 1
			if child_bad + p[v] < v_bad:
				break
		else:
			ans[ti] = 'YES'
	sys.stdout.buffer.write(('\n'.join(ans) + '\n').encode('utf-8'))
main()


import sys
input = sys.stdin.readline
import heapq
import copy
import math
import decimal

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

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

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

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

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

def pr_list(a):
	print(*a, sep=' ')

def main():
	tests = inp()
	mod = 1000000007
	limit = 10 ** 18
	ans = 0
	stack = []
	hashm = {}
	arr = []
	heapq.heapify(arr)
	for test in range(tests):
		[n, m] = inlt()
		people = inlt()
		happ = inlt()
		happ = [0] + happ
		people = [0] + people
		grid = [{} for i in range(n + 1)]
		for i in range(n - 1):
			[a, b] = inlt()
			grid[a][b] = 1
			grid[b][a] = 1
		sad = [0 for i in range(n + 1)]
		trans = [0 for i in range(n + 1)]
		done = [0 for i in range(n + 1)]
		parent = [0 for i in range(n + 1)]
		stack = [1]
		flag = 0
		while stack != []:
			curr = stack[-1]
			done[curr] = 1
			flag2 = 0
			for i in grid[curr]:
				if curr in grid[i]:
					del grid[i][curr]
				if done[i] != 1:
					done[i] = 1
					flag2 = 1
					stack.append(i)
			if flag2 == 0:
				curr = stack.pop()
				min_sad = 0
				for i in grid[curr]:
					trans[curr] = trans[curr] + trans[i]
					min_sad = sad[i] + min_sad
				trans[curr] = trans[curr] + people[curr]
				good = (happ[curr] + trans[curr]) // 2
				bad = (trans[curr] - happ[curr]) // 2
				if bad - people[curr] > min_sad or (trans[curr] - happ[curr]) % 2 != 0 or (happ[curr] + trans[curr]) % 2 != 0 or (trans[curr] - happ[curr] < 0) or (happ[curr] + trans[curr] < 0):
					flag = 1
					break
				sad[curr] = bad
		if flag == 1:
			print('No')
		else:
			print('Yes')
main()


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

class FastIO(IOBase):
	newlines = 0

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

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

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

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

class IOWrapper(IOBase):

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

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

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

def N():
	return int(input())

def print_list(l):
	print(' '.join(map(str, l)))
from collections import defaultdict as dc
for _ in range(N()):
	(n, m) = RL()
	p = RLL()
	h = RLL()
	dic = dc(list)
	for _ in range(n - 1):
		(u, v) = RL()
		dic[u].append(v)
		dic[v].append(u)
	gress = [0] * (n + 1)
	now = []
	for i in range(1, n + 1):
		gress[i] = len(dic[i])
		if gress[i] == 1 and i != 1:
			now.append(i)
	gres = gress.copy()
	no = now.copy()
	dpn = [0] * (n + 1)
	while now:
		node = now.pop()
		dpn[node] += p[node - 1]
		gress[node] = 0
		for i in dic[node]:
			if gress[i] > 0:
				dpn[i] += dpn[node]
				gress[i] -= 1
				if gress[i] == 1 and i != 1:
					now.append(i)
	dpn[1] += p[0]
	dhn = [0] * (n + 1)
	flag = True
	while no:
		node = no.pop()
		dhn[node] += h[node - 1] + dpn[node] >> 1
		if dhn[node] < 0 or h[node - 1] > dpn[node] or h[node - 1] < -1 * dpn[node] or (h[node - 1] & 1 != dpn[node] & 1):
			flag = False
			break
		gres[node] = 0
		for i in dic[node]:
			if gres[i] > 0:
				dhn[i] -= h[node - 1] + dpn[node] >> 1
				gres[i] -= 1
				if gres[i] == 1 and i != 1:
					no.append(i)
	dhn[1] += h[0] + dpn[1] >> 1
	node = 1
	if dhn[1] < 0 or h[node - 1] > dpn[node] or h[node - 1] < -1 * dpn[node] or (h[node - 1] & 1 != dpn[node] & 1):
		flag = False
	if flag:
		print('YES')
	else:
		print('NO')


from sys import stdin
import sys
sys.setrecursionlimit(300000)

def dfs(v, pa):
	good = 0
	bad = 0
	for nex in lis[v]:
		if nex != pa:
			(nans, ng, nb) = dfs(nex, v)
			if not nans:
				return (nans, 0, 0)
			good += ng
			bad += nb
	num = good + bad + p[v]
	if (num - h[v]) % 2 == 0:
		newbad = (num - h[v]) // 2
	else:
		return (False, 0, 0)
	newgood = num - newbad
	if newbad - p[v] > bad or newgood < good or newbad < 0 or (newgood < 0):
		return (False, 0, 0)
	else:
		return (True, newgood, newbad)
tt = int(stdin.readline())
for loop in range(tt):
	(n, m) = map(int, stdin.readline().split())
	p = list(map(int, stdin.readline().split()))
	h = list(map(int, stdin.readline().split()))
	lis = [[] for i in range(n)]
	for i in range(n - 1):
		(v, u) = map(int, stdin.readline().split())
		v -= 1
		u -= 1
		lis[v].append(u)
		lis[u].append(v)
	(ans, good, bad) = dfs(0, 0)
	if ans:
		print('YES')
	else:
		print('NO')


import sys
input = sys.stdin.readline
for t in range(int(input())):
	(n, m) = map(int, input().split())
	p = list(map(int, input().split()))
	h = list(map(int, input().split()))
	chi = [[] for i in range(n)]
	vis = [-1 for i in range(n)]
	ha = [0 for i in range(n)]
	for i in range(n - 1):
		(v1, v2) = map(int, input().split())
		chi[v1 - 1].append(v2 - 1)
		chi[v2 - 1].append(v1 - 1)
	ans = 'YES'
	dfsw = [0]
	while len(dfsw) > 0:
		curr = dfsw[-1]
		cont = 1
		for i in chi[curr]:
			if vis[i] == -1:
				chi[i].remove(curr)
				dfsw.append(i)
				cont = 0
				break
		if cont == 1:
			c = p[curr]
			for i in chi[curr]:
				c += vis[i]
			vis[curr] = c
			if (vis[curr] + h[curr]) % 2 == 1 or vis[curr] < h[curr]:
				ans = 'NO'
			ha[curr] = (vis[curr] + h[curr]) // 2
			hc = 0
			for j in chi[curr]:
				hc += ha[j]
			if ha[curr] < hc:
				ans = 'NO'
			dfsw.pop(-1)
	print(ans)


import sys
sys.setrecursionlimit(320000)
input = sys.stdin.readline

def dfs(x, pa):
	g = 0
	b = 0
	for nex in e[x]:
		if nex == pa:
			continue
		(ng, nb, check) = dfs(nex, x)
		if check == False:
			return (0, 0, False)
		g += ng
		b += nb
	c = p[x]
	num = h[x]
	if num % 2 != (c % 2 + (g - b) % 2) % 2:
		return (0, 0, False)
	if num > g + b + c or num < g - b - c:
		return (0, 0, False)
	now = g - b
	if num >= now:
		g += num - now
		g += (c - num + now) // 2
		b += (c - num + now) // 2
	else:
		b += now - num
		g += (c + num - now) // 2
		b += (c + num - now) // 2
	return (g, b, True)
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	p = list(map(int, input().split()))
	h = list(map(int, input().split()))
	e = [[] for i in range(n)]
	for i in range(n - 1):
		(a, b) = map(int, input().split())
		a -= 1
		b -= 1
		e[a].append(b)
		e[b].append(a)
	(g, b, check) = dfs(0, -1)
	if check:
		print('YES')
	else:
		print('NO')


import sys
sys.setrecursionlimit(1000000)
input = sys.stdin.readline
read = lambda : map(int, input().split())

def ceil(x):
	if x != int(x):
		x = int(x) + 1
	return x

def factorial(x, m):
	val = 1
	while x > 0:
		val = val * x % m
		x -= 1
	return val

def fact(x):
	val = 1
	while x > 0:
		val *= x
		x -= 1
	return val

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

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

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

def nCr(n, k):
	if k > n:
		return 0
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

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 swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

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

def phi(n):
	result = n
	p = 2
	while p * p <= n:
		if n % p == 0:
			while n % p == 0:
				n = n // p
			result = result * (1.0 - 1.0 / float(p))
		p = p + 1
	if n > 1:
		result = result * (1.0 - 1.0 / float(n))
	return int(result)

def is_prime(n):
	if n == 0:
		return False
	if n == 1:
		return True
	for i in range(2, int(n ** (1 / 2)) + 1):
		if not n % i:
			return False
	return True
MAXN = int(100000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i
spf = [0 for i in range(MAXN)]

def factoriazation(x):
	res = []
	for i in range(2, int(x ** 0.5) + 1):
		while x % i == 0:
			res.append(i)
			x //= i
	if x != 1:
		res.append(x)
	return res

def factors(n):
	res = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			res.append(i)
			res.append(n // i)
	return list(set(res))

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

def float_array():
	return list(map(float, input().strip().split()))

def str_array():
	return input().strip().split()

def binary_search(low, high, w, h, n):
	while low < high:
		mid = low + (high - low) // 2
		if check(mid, w, h, n):
			high = mid
		else:
			low = mid + 1
	return low

def check(time, x, y, n):
	time -= min(x, y)
	if time < 0:
		return False
	return time // x + time // y + 1 >= n
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
from itertools import permutations
import math
import bisect as bis
import random
import sys

def dfs(x, par):
	global f
	tot[x] = p[x]
	sumgd = 0
	for v in g[x]:
		if v != par:
			dfs(v, x)
			tot[x] += tot[v]
			sumgd += gd[v]
	if (tot[x] + h[x]) % 2 == 1:
		f = 1
	gd[x] = (tot[x] + h[x]) // 2
	if gd[x] < 0 or gd[x] > tot[x]:
		f = 1
	if sumgd > gd[x]:
		f = 1
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	p = [-1] + list(map(int, input().split()))
	h = [-1] + list(map(int, input().split()))
	g = [[] for i in range(n + 1)]
	f = 0
	for i in range(n - 1):
		(x, y) = map(int, input().split())
		g[x].append(y)
		g[y].append(x)
	tot = [0] * (n + 1)
	gd = [0] * (n + 1)
	dfs(1, 0)
	if f:
		print('NO')
	else:
		print('YES')


from collections import deque as dq
from collections import defaultdict as dd
from collections import Counter as ct
from functools import lru_cache as lc
from heapq import heappush as hpush, heappop as hpop, heapify as hfy
from bisect import bisect_left, bisect_right
import itertools as it
import math
import sys
sys.setrecursionlimit(10 ** 9)

def solve():
	(n, m) = map(int, input().split())
	P = list(map(int, input().split()))
	H = list(map(int, input().split()))
	edges = [[] for i in range(n)]
	for _ in range(n - 1):
		(u, v) = map(int, input().split())
		(u, v) = (u - 1, v - 1)
		edges[u].append(v)
		edges[v].append(u)

	def dfs(cur, prev):
		ret = True
		happy = unhappy = 0
		for nxt in edges[cur]:
			if nxt == prev:
				continue
			(sub_ret, sub_happy, sub_unhappy) = dfs(nxt, cur)
			ret &= sub_ret
			happy += sub_happy
			unhappy += sub_unhappy
		unhappy += P[cur]
		h = happy - unhappy
		if H[cur] < h:
			ret = False
		if happy + unhappy < abs(H[cur]):
			ret = False
		if H[cur] % 2 != h % 2:
			ret = False
		happy += (H[cur] - h) // 2
		unhappy -= (H[cur] - h) // 2
		return (ret, happy, unhappy)
	print('YES' if dfs(0, -1)[0] else 'NO')
T = int(input())
for t in range(T):
	solve()


import sys
sys.setrecursionlimit(250000)
input = sys.stdin.readline
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	population = list(map(int, input().split()))
	happiness = list(map(int, input().split()))
	AdjList = [[] for _ in range(n)]
	for _ in range(n - 1):
		(u, v) = map(lambda x: int(x) - 1, input().split())
		AdjList[u].append(v)
		AdjList[v].append(u)
	stack = [(0, -1)]
	TopSorted = list()
	while stack:
		(node, parent) = stack.pop()
		TopSorted.append((node, parent))
		for child in AdjList[node]:
			if child != parent:
				stack.append((child, node))
	happy_traveller = [0] * n
	flag = False
	while TopSorted:
		(node, parent) = TopSorted.pop()
		happy_total = (population[node] + happiness[node]) // 2
		if happy_total < 0 or happy_total > population[node] or (population[node] - happiness[node]) % 2 == 1 or (happy_total < happy_traveller[node]):
			flag = True
			break
		if parent != -1:
			happy_traveller[parent] += happy_total
			population[parent] += population[node]
	if flag == False:
		print('YES')
	else:
		print('NO')


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')
from collections import deque as que, defaultdict as vector
from bisect import bisect as bsearch
from heapq import *
inin = lambda : int(input())
inar = lambda : list(map(int, input().split()))
power2 = lambda n: n & n - 1 == 0
INF = float('inf')
from types import GeneratorType

def bootstrap(f, stack=[]):

	def wrappedfunc(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		else:
			to = f(*args, **kwargs)
			while True:
				if type(to) is GeneratorType:
					stack.append(to)
					to = next(to)
				else:
					stack.pop()
					if not stack:
						break
					to = stack[-1].send(to)
			return to
	return wrappedfunc
ans = ''

@bootstrap
def dfs(graph, node, par, vis, h, p):
	global ans
	check = 0
	vis[node] = p[node]
	for child in graph[node]:
		if child != par:
			vis[node] += (yield dfs(graph, child, node, vis, h, p))
			check += h[child]
	if (vis[node] + h[node]) % 2:
		ans = 'NO'
	if abs(h[node]) > vis[node]:
		ans = 'NO'
	if check > p[node] + h[node]:
		ans = 'NO'
	yield vis[node]
Testcase = inin()
for Case in range(Testcase):
	ans = 'YES'
	(n, m) = inar()
	p = [0] + inar()
	h = [m + 8] + inar()
	vis = [0 for i in range(n + 1)]
	graph = [[] for i in range(n + 1)]
	for i in range(n - 1):
		(a, b) = inar()
		graph[a].append(b)
		graph[b].append(a)
	dfs(graph, 1, 0, vis, h, p)
	print(ans)


from collections import defaultdict
from sys import setrecursionlimit, stdin
input = stdin.readline
import threading
setrecursionlimit(30000)
flag = False

def dfs(node, parent, person, factor, happy, g):
	th = 0
	global flag
	for i in g[node]:
		if i != parent:
			th += dfs(i, node, person, factor, happy, g)
			person[node] += person[i]
	if (person[node] + factor[node]) % 2 != 0:
		flag = True
	x = (person[node] + factor[node]) // 2 - th
	if x < 0 or factor[node] > person[node]:
		flag = True
	else:
		happy[node] = x + th
	return x + th

def main():
	global flag
	for _ in range(int(input())):
		(n, m) = map(int, input().strip().split())
		g = defaultdict(list)
		person = list(map(int, input().strip().split()))
		factor = list(map(int, input().strip().split()))
		for i in range(n - 1):
			(x, y) = map(int, input().strip().split())
			g[x - 1].append(y - 1)
			g[y - 1].append(x - 1)
		happy = [0] * n
		flag = False
		l = dfs(0, -1, person, factor, happy, g)
		if flag:
			print('NO')
		else:
			print('YES')
threading.stack_size(10 ** 8)
t = threading.Thread(target=main)
t.start()
t.join()


from types import GeneratorType
import sys
input = sys.stdin.readline

def bootstrap(f, stack=[]):

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

class Graph:

	def __init__(self, V):
		self.V = V
		self.adj = [[] for i in range(V)]

	@bootstrap
	def DFSUtil(self, temp, v, visited, passed, citizens, h):
		visited[v] = True
		passed[v] += citizens[v]
		temp.append(v)
		for i in self.adj[v]:
			if visited[i] == False:
				temp = (yield self.DFSUtil(temp, i, visited, passed, citizens, h))
				passed[v] += passed[i]
		yield temp

	@bootstrap
	def DFSUtil_v2(self, v, visited, passed, citizens, h):
		visited[v] = True
		total_negative_children = 0
		if h[v] < -passed[v] or h[v] > passed[v]:
			yield (-1)
		for i in self.adj[v]:
			if visited[i] == False:
				total_negative_children += (passed[i] - h[i]) // 2
				temp = (yield self.DFSUtil_v2(i, visited, passed, citizens, h))
				if temp == -1:
					yield (-1)
		x = (passed[v] - h[v]) // 2
		if (passed[v] - h[v]) % 2 != 0:
			yield (-1)
		if x - citizens[v] <= total_negative_children:
			yield 1
		else:
			yield (-1)

	def addEdge(self, v, w):
		self.adj[v].append(w)
		self.adj[w].append(v)
t = int(input())
for _ in range(t):
	(n, m) = list(map(int, input().split()))
	p = list(map(int, input().split()))
	h = list(map(int, input().split()))
	G = Graph(n)
	for _ in range(n - 1):
		(u, v) = list(map(int, input().split()))
		u -= 1
		v -= 1
		G.addEdge(u, v)
	passed = [0 for _ in range(n)]
	visited = [0 for _ in range(n)]
	G.DFSUtil([], 0, visited, passed, p, h)
	visited = [0 for _ in range(n)]
	ans = G.DFSUtil_v2(0, visited, passed, p, h)
	if ans == -1:
		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')
from collections import deque, defaultdict
for j in range(int(input())):
	(n, m) = map(int, input().split())
	graph = [[] for s in range(n)]
	liv = list(map(int, input().split()))
	hap = list(map(int, input().split()))
	for s in range(n - 1):
		(u, v) = map(int, input().split())
		u -= 1
		v -= 1
		graph[u].append(v)
		graph[v].append(u)
	queue = deque([0])
	vis = set([0])
	pr = 1
	cv = 0
	depth = defaultdict(list)
	dd = {}
	while len(queue) > 0:
		v0 = queue.popleft()
		for node in graph[v0]:
			if not node in vis:
				queue.append(node)
				vis.add(node)
		pr -= 1
		depth[cv].append(v0)
		dd[v0] = cv
		if pr == 0:
			cv += 1
			pr = len(queue)
	cv -= 1
	travel = defaultdict(int)
	for s in range(n):
		travel[s] = liv[s]
	while cv > 0:
		for s in depth[cv]:
			for i in graph[s]:
				if dd[i] < cv:
					travel[i] += travel[s]
		cv -= 1
	q2 = deque([0])
	v2 = set([0])
	broke = False
	while len(q2) > 0:
		v1 = q2.pop()
		happiness = hap[v1]
		passthrough = travel[v1]
		sumchild = 0
		exist = False
		for s in graph[v1]:
			if not s in v2:
				q2.append(s)
				v2.add(s)
				sumchild += hap[s]
				exist = True
		if sumchild > happiness + liv[v1]:
			broke = True
			break
		if (happiness + passthrough) % 2 == 1:
			broke = True
			break
		else:
			a = (happiness + passthrough) // 2
			b = passthrough - a
			if a < 0 or b < 0:
				broke = True
				break
	if broke == False:
		print('YES')
	else:
		print('NO')


from sys import stdin, gettrace
from collections import deque
if gettrace():
	inputi = input
else:

	def input():
		return next(stdin)[:-1]

	def inputi():
		return stdin.buffer.readline()

def readGraph(n, m):
	adj = [set() for _ in range(n)]
	for _ in range(m):
		(u, v) = map(int, inputi().split())
		adj[u - 1].add(v - 1)
		adj[v - 1].add(u - 1)
	return adj

def readTree(n):
	return readGraph(n, n - 1)

def treeOrderByDepth(n, adj, root=0):
	parent = [-1] * n
	parent[root] = -2
	ordered = []
	q = deque()
	q.append(root)
	while q:
		c = q.popleft()
		ordered.append(c)
		for a in adj[c]:
			if parent[a] == -1:
				parent[a] = c
				q.append(a)
	return (ordered, parent)

def solve():
	(n, m) = map(int, inputi().split())
	pp = [int(a) for a in inputi().split()]
	hh = [int(a) for a in inputi().split()]
	adj = readTree(n)
	(ordered, parent) = treeOrderByDepth(n, adj)
	psum = [0] * n
	hsum = [0] * n
	for i in ordered[::-1]:
		if hh[i] < -pp[i] + hsum[i] or hh[i] > pp[i] + psum[i]:
			print('NO')
			return
		if (hh[i] + pp[i] + psum[i]) % 2 != 0:
			print('NO')
			return
		if i != 0:
			hsum[parent[i]] += hh[i]
			psum[parent[i]] += psum[i] + pp[i]
	print('YES')

def main():
	t = int(inputi())
	for _ in range(t):
		solve()
main()


import os
import operator
import sys, threading
import bisect
import _operator
from _collections import defaultdict, deque
from io import BytesIO, IOBase
sys.setrecursionlimit(10 ** 6)
threading.stack_size(2 ** 25)

def inar():
	return [int(k) for k in input().split()]

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

def dfs(node, adj, visited, people, happy, total, good, bad):
	global pos
	bad_child = 0
	visited[node] = 1
	total[node] = people[node]
	for child in adj[node]:
		if not visited[child]:
			dfs(child, adj, visited, people, happy, total, good, bad)
			total[node] += total[child]
			bad_child += bad[child]
	if happy[node] > total[node]:
		pos = 1
	if happy[node] < -1 * total[node]:
		pos = 1
	if (total[node] + happy[node]) % 2 != 0:
		pos = 1
	good[node] = (total[node] + happy[node]) // 2
	bad[node] = (total[node] - happy[node]) // 2
	if bad[node] > people[node] + bad_child:
		pos = 1

def main():
	for _ in range(int(input())):
		global pos
		pos = 0
		(n, m) = map(int, input().split())
		people = inar()
		happy = inar()
		happy.insert(0, 0)
		people.insert(0, 0)
		adj = defaultdict(list)
		total = [0] * (n + 1)
		visited = [0] * (n + 1)
		bad = [0] * (n + 1)
		good = [0] * (n + 1)
		for i in range(n - 1):
			(u, v) = map(int, input().split())
			adj[u].append(v)
			adj[v].append(u)
		dfs(1, adj, visited, people, happy, total, good, bad)
		if pos == 1:
			print('NO')
		else:
			print('YES')
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')
threading.Thread(target=main).start()


import os
os_input = os.read(0, int(10000000.0)).split()
os_input_pos = -1
answer_list = []

def read_s():
	global os_input_pos
	os_input_pos += 1
	return os_input[os_input_pos].decode()

def read_i():
	return int(read_s())

def write_s(v):
	answer_list.append(v)

def write_i(v):
	write_s(str(v))

def print_ans():
	os.write(1, '\n'.join(answer_list).encode())
	os.write(1, '\n'.encode())
from types import GeneratorType

def iterative(f, stack=[]):

	def wrappedfunc(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		else:
			to = f(*args, **kwargs)
			while True:
				if type(to) is GeneratorType:
					stack.append(to)
					to = next(to)
				else:
					stack.pop()
					if not stack:
						break
					to = stack[-1].send(to)
			return to
	return wrappedfunc
T = read_i()
while T:
	T -= 1
	n = read_i()
	m = read_i()
	sz = [read_i() for i in range(n)]
	val = [read_i() for i in range(n)]
	adj = [[] for i in range(n)]
	for i in range(n - 1):
		a = read_i() - 1
		b = read_i() - 1
		adj[a].append(b)
		adj[b].append(a)

	@iterative
	def dfs(u, p):
		orig = sz[u]
		bcnt = 0
		for v in adj[u]:
			if v == p:
				continue
			(ok, bad) = (yield dfs(v, u))
			if not ok:
				yield (False, 0)
			sz[u] += sz[v]
			bcnt += bad
		cbad = sz[u] - val[u]
		if cbad % 2 or cbad < 0 or cbad // 2 > sz[u] or (cbad // 2 > bcnt + orig):
			yield (False, 0)
		yield (True, cbad // 2)
	if dfs(0, 0)[0]:
		write_s('YES')
	else:
		write_s('NO')
print_ans()


from collections import deque

def solve():
	(n, m) = map(int, input().split())
	P = list(map(int, input().split()))
	H = list(map(int, input().split()))
	E = [[] for _ in range(n)]
	for _ in range(n - 1):
		(x, y) = map(lambda x: int(x) - 1, input().split())
		E[x].append(y)
		E[y].append(x)
	parent = [0] * n
	d = deque([0])
	V = [False] * n
	V[0] = True
	C = []
	while d:
		v = d.popleft()
		C.append(v)
		for w in E[v]:
			if not V[w]:
				d.append(w)
				V[w] = True
				parent[w] = v
	AP = [p for p in P]
	for v in C[::-1]:
		if v == 0:
			continue
		AP[parent[v]] += AP[v]
	no = 'NO'
	G = [0] * n
	B = [0] * n
	for i in range(n):
		(h, p) = (H[i], AP[i])
		if (h + p) % 2 == 0 and p - h >= 0 and (h + p >= 0):
			G[i] = (h + p) // 2
			B[i] = (p - h) // 2
		else:
			return no
	V = [False] * n
	V[0] = True
	for v in C:
		good = 0
		bad = 0
		for w in E[v]:
			if not V[w]:
				good += G[w]
				V[w] = True
		if good > G[v]:
			return no
	return 'YES'

def main():
	t = int(input())
	ANS = [solve() for _ in range(t)]
	print('\n'.join(ANS))
main()


import sys
sys.setrecursionlimit(10 ** 6)
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	p = list(map(int, input().split()))
	h = list(map(int, input().split()))
	g = [[] for i in range(n)]
	an = 'YES'
	c = [0] * n
	for i in range(n - 1):
		(u, v) = map(int, input().split())
		g[u - 1].append(v - 1)
		g[v - 1].append(u - 1)

	def dfs(v, pa):
		d = 0
		for i in g[v]:
			if i != pa:
				d += dfs(i, v)
		c[v] = d + p[v]
		return c[v]
	dfs(0, -1)

	def df(v, pa):
		d = h[v]
		cr = c[v]
		bd = (cr - h[v]) // 2
		gd = cr - bd
		pos = 1
		aa = 0
		bb = 0
		for i in g[v]:
			if i != pa:
				kk = c[i]
				bh = (c[i] - h[i]) // 2
				gh = c[i] - bh
				aa += gh
				bb += bh
				pos = min(pos, df(i, v))
		if c[v] < abs(h[v]) or (cr - h[v]) % 2:
			return 0
		if aa <= gd and bb <= bd + (gd - aa):
			return pos
		return 0
	po = df(0, -1)
	if not po:
		an = 'NO'
	print(an)


n = int(input())
from collections import defaultdict
import math

def compute_helper(TOT_POPS, graph, pop_cities):
	children = defaultdict(list)
	STACK = []
	VISITED = {}
	VISITED[1] = True
	initial_city = 1
	STACK.append(initial_city)
	while len(STACK) != 0:
		curr_city = STACK[-1]
		if len(graph[curr_city]) == 1 and curr_city != 1:
			TOT_POPS[curr_city] = pop_cities[curr_city]
			STACK.pop()
			continue
		for child in graph[curr_city]:
			if child not in VISITED:
				STACK.append(child)
				children[curr_city].append(child)
				VISITED[child] = True
		if all([child in TOT_POPS for child in children[curr_city]]):
			STACK.pop()
			TOT_POPS[curr_city] = pop_cities[curr_city] + sum([TOT_POPS[child] for child in children[curr_city]])

def compute_total_population(marker, TOT_POPS, city, graph, pop_cities):
	total_population = pop_cities[city]
	marker[city] = True
	for child_city in graph[city]:
		if child_city in marker:
			continue
		if len(graph[child_city]) == 1:
			total_population += pop_cities[child_city]
			TOT_POPS[child_city] = pop_cities[child_city]
		else:
			total_population += compute_total_population(marker, TOT_POPS, child_city, graph, pop_cities)
	TOT_POPS[city] = total_population
	return total_population

def non_recursive_explore(TOT_POPS, happiness_by_city, graph):
	STACK = [1]
	VISITED = {}
	VISITED[1] = True
	children = defaultdict(list)
	NB_HAPPY = {}
	while len(STACK) != 0:
		curr_city = STACK[-1]
		if (TOT_POPS[curr_city] - happiness_by_city[curr_city]) % 2 == 0 and abs(happiness_by_city[curr_city]) <= TOT_POPS[curr_city]:
			pass
		else:
			return False
		if len(graph[curr_city]) == 1 and curr_city != 1:
			NB_HAPPY[curr_city] = int((TOT_POPS[curr_city] + happiness_by_city[curr_city]) / 2)
			STACK.pop()
			continue
		for child_city in graph[curr_city]:
			if child_city not in VISITED:
				VISITED[child_city] = True
				children[curr_city].append(child_city)
				STACK.append(child_city)
		if all([child in NB_HAPPY for child in children[curr_city]]):
			nb_happy_person_in_children = sum([NB_HAPPY[child] for child in children[curr_city]])
			nb_happy_person_in_parent = (happiness_by_city[curr_city] + TOT_POPS[curr_city]) // 2
			nb_unhappy_people = (TOT_POPS[curr_city] - happiness_by_city[curr_city]) // 2
			nb_of_happy_person_left_behind = population_by_city[curr_city] - nb_unhappy_people
			nb_of_happy_person_left_behind = nb_of_happy_person_left_behind if nb_of_happy_person_left_behind > 0 else 0
			if nb_happy_person_in_children <= nb_happy_person_in_parent - nb_of_happy_person_left_behind:
				NB_HAPPY[curr_city] = nb_happy_person_in_parent
				STACK.pop()
				continue
			else:
				return False
	return True
__import__('sys').setrecursionlimit(5056)

def explore(city, marker, TOT_POPS, happiness_by_city, graph):
	marker[city] = True
	nb_happy_person_in_parent = int((TOT_POPS[city] + happiness_by_city[city]) / 2)
	nb_happy_person_in_children = 0
	if len(graph[city]) == 1 and city != 1:
		if (TOT_POPS[city] - happiness_by_city[city]) % 2 == 0:
			return True
		else:
			return False
	for child_city in graph[city]:
		try:
			if child_city not in marker:
				if abs(happiness_by_city[child_city]) > TOT_POPS[child_city]:
					return False
				nb_happy_person_in_children += int((TOT_POPS[child_city] + happiness_by_city[child_city]) / 2)
				VALID = explore(child_city, marker, TOT_POPS, happiness_by_city, graph)
				if not VALID:
					return False
		except Exception as e:
			print(traceback.format_exc())
	nb_of_happy_person_left_behind = population_by_city[city] - int((TOT_POPS[city] - happiness_by_city[city]) / 2) if population_by_city[city] - int((TOT_POPS[city] - happiness_by_city[city]) / 2) > 0 else 0
	if nb_happy_person_in_children <= nb_happy_person_in_parent - nb_of_happy_person_left_behind and abs(happiness_by_city[city]) <= TOT_POPS[city] and ((TOT_POPS[city] - happiness_by_city[city]) % 2 == 0):
		return True
	else:
		return False
for _ in range(n):
	TOT_POPS = {}
	graph = defaultdict(list)
	(nb_cities, nb_citizens) = map(int, input().split())
	population_by_city = [0] + list(map(int, input().split()))
	happiness_by_city = [0] + list(map(int, input().split()))
	for _ in range(nb_cities - 1):
		(city1, city2) = map(int, input().split())
		graph[city1].append(city2)
		graph[city2].append(city1)
	marker0 = {}
	import traceback
	try:
		compute_helper(TOT_POPS, graph, population_by_city)
	except Exception as e:
		print(e)
		print(traceback.format_exc())
		exit(1)
	try:
		marker = {}
		if explore(1, marker, TOT_POPS, happiness_by_city, graph):
			print('YES')
		else:
			print('NO')
	except Exception as e:
		print(e)


import os
import heapq
import sys
import math
import operator
from collections import defaultdict, deque
from io import BytesIO, IOBase
sys.setrecursionlimit(10 ** 5)

def inpt():
	return [int(k) for k in input().split()]

class result:
	res = True

def dfs(d, s, visited, p, h):
	visited.add(s)
	good = 0
	move = 0
	total = 0
	for i in d[s]:
		if i not in visited:
			(a, b) = dfs(d, i, visited, p, h)
			good += a
			total += b
	if result.res == False:
		return (-1, -1)
	total += p[s - 1]
	hp = h[s - 1] + total
	if hp % 2 != 0:
		result.res = False
		return (-1, -1)
	hp = hp // 2
	if not 0 <= hp <= total:
		result.res = False
		return (-1, -1)
	if good > hp:
		result.res = False
		return (-1, -1)
	return (hp, total)

def main():
	for _ in range(int(input())):
		result.res = True
		(n, m) = map(int, input().split())
		p = inpt()
		h = inpt()
		d = defaultdict(list)
		for i in range(n - 1):
			(a, b) = map(int, input().split())
			d[a].append(b)
			d[b].append(a)
		visited = set()
		(a, b) = dfs(d, 1, visited, p, h)
		if result.res == True:
			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')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


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))
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(a, b):
	ans = 1
	while b > 0:
		if b % 2 == 1:
			ans *= a
		a *= a
		b //= 2
	return ans

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

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

def bfs(g, st, par):
	visited = [-1] * len(g)
	visited[st] = 0
	queue = []
	queue.append(st)
	new = []
	while len(queue) != 0:
		s = queue.pop()
		new.append(s)
		for i in g[s]:
			if visited[i] == -1:
				par[i] = s
				visited[i] = visited[s] + 1
				queue.append(i)
	return visited

def dfsusingstack(v, st, cnt, p):
	d = deque([])
	d.append(st)
	visited = [0] * len(v)
	visited[st] = 1
	new = []
	while len(d) != 0:
		curr = d.pop()
		new.append(curr)
		for i in v[curr]:
			if visited[i] == 0:
				visited[i] = 1
				d.append(i)
	return new

def solve():
	(n, m) = sep()
	p = lis()
	h = lis()
	chi = [[] for i in range(n)]
	vis = [-1 for i in range(n)]
	ha = [0 for i in range(n)]
	for i in range(n - 1):
		(v1, v2) = map(int, input().split())
		chi[v1 - 1].append(v2 - 1)
		chi[v2 - 1].append(v1 - 1)
	ans = 'YES'
	dfsw = [0]
	while len(dfsw) > 0:
		curr = dfsw[-1]
		cont = 1
		for i in chi[curr]:
			if vis[i] == -1:
				chi[i].remove(curr)
				dfsw.append(i)
				cont = 0
				break
		if cont == 1:
			c = p[curr]
			for i in chi[curr]:
				c += vis[i]
			vis[curr] = c
			if (vis[curr] + h[curr]) % 2 == 1 or vis[curr] < h[curr]:
				ans = 'NO'
			ha[curr] = (vis[curr] + h[curr]) // 2
			hc = 0
			for j in chi[curr]:
				hc += ha[j]
			if ha[curr] < hc:
				ans = 'NO'
			dfsw.pop(-1)
	print(ans)
testcase(int(inp()))


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

def bfs(node):
	vis[node] = 1
	q = deque([node])
	arr = []
	while q:
		cur = q.popleft()
		arr.append(cur)
		for j in edge[cur]:
			if vis[j] == 0:
				vis[j] = 1
				q.append(j)
				child[cur].append(j)
	arr.reverse()
	return arr
t = int(input())
for _ in range(t):
	(n, m) = list(map(int, input().split()))
	p = list(map(int, input().split()))
	h = list(map(int, input().split()))
	edge = defaultdict(list)
	child = defaultdict(list)
	for i in range(n - 1):
		(u, v) = list(map(int, input().split()))
		edge[u].append(v)
		edge[v].append(u)
	vis = [0] * (n + 1)
	arr = bfs(1)
	lis = []
	for i in range(n):
		lis.append(p[i])
	for i in arr:
		for j in child[i]:
			lis[i - 1] += lis[j - 1]
	num = []
	s = 0
	for i in range(n):
		a = lis[i] - abs(h[i])
		if a < 0:
			s += 1
			break
		elif a % 2 == 1:
			s += 1
			break
		else:
			b = a // 2
			if h[i] == 0:
				num.append([lis[i] // 2, lis[i] // 2])
			elif h[i] > 0:
				num.append([h[i] + b, b])
			else:
				num.append([b, abs(h[i]) + b])
	if s == 1:
		print('NO')
	else:
		for i in arr:
			x = 0
			y = 0
			for j in child[i]:
				x += num[j - 1][0]
				y += num[j - 1][1]
			if x > num[i - 1][0]:
				s += 1
				break
		if s == 1:
			print('NO')
		else:
			print('YES')


import sys, math
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)
t = int(input())

def numberOfNodes(s, e, p):
	countPeople[s] = p[s]
	for u in graph[s]:
		if u == e:
			continue
		parents[u] = s
		numberOfNodes(u, s, p)
		countPeople[s] += countPeople[u]
for r in range(t):
	(n, m) = map(int, input().split())
	p = list(map(int, input().split()))
	h = list(map(int, input().split()))
	graph = []
	for i in range(n):
		graph.append([])
	for i in range(n - 1):
		(v, u) = map(int, input().split())
		v -= 1
		u -= 1
		graph[v].append(u)
		graph[u].append(v)
	countPeople = [0] * n
	parents = [0] * n
	parents[0] = -1
	numberOfNodes(0, -1, p)
	happyPeople = [0] * n
	sadPeople = [0] * n
	flag = True
	for v in range(n):
		if countPeople[v] % 2 != h[v] % 2:
			flag = False
			break
		happyPeople[v] = (countPeople[v] + h[v]) // 2
		sadPeople[v] = countPeople[v] - happyPeople[v]
		if happyPeople[v] < 0 or sadPeople[v] < 0:
			flag = False
			break
	if flag == False:
		print('NO')
	else:
		flag2 = True
		for v in range(n):
			sumHappy = 0
			for u in graph[v]:
				if u != parents[v]:
					sumHappy += happyPeople[u]
			if sumHappy > happyPeople[v]:
				flag2 = False
				break
		if flag2 == False:
			print('NO')
		else:
			print('YES')


from bisect import bisect_left as bl
from bisect import bisect_right as br
from heapq import heappush, heappop, heapify
import math
from collections import *
from functools import reduce, cmp_to_key
import sys
input = sys.stdin.readline
from itertools import accumulate
M = mod = 998244353

def factors(n):
	return sorted(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0))))

def inv_mod(n):
	return pow(n, mod - 2, mod)

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')]

def li3():
	return [int(i) for i in input().rstrip('\n')]
ans = 1
h = p = su = g = n = 0

def bfs(root=1):
	global ans, h, p, su, g, n
	d = deque()
	d.append([1, 0])
	l1 = []
	parent = {}
	maxcounts = defaultdict(int)
	for j in range(1, n + 1):
		maxcounts[j] = p[j]
	while d:
		(root, par) = d.popleft()
		l1.append(root)
		parent[root] = par
		for j in g[root]:
			if j != par:
				d.append([j, root])
	l1.reverse()
	for j in l1:
		curr = maxcounts[j]
		if h[j] < -curr or h[j] > curr or curr - h[j] & 1:
			ans = 0
			return
		maxcounts[parent[j]] += curr
	d = deque()
	d.append([1, 0])
	while d:
		(root, par) = d.popleft()
		curr = h[root]
		temp = curr + p[root]
		if temp > maxcounts[root]:
			ma_range = maxcounts[root] - (temp - maxcounts[root])
		else:
			ma_range = temp
		goneit = 0
		subtree_happiness = 0
		for j in g[root]:
			if j != par:
				goneit = 1
				subtree_happiness += h[j]
				d.append([j, root])
		if par and goneit and (subtree_happiness > ma_range):
			ans = 0
			break
	if not ans:
		return
	d = deque()
	d.append([1, 0])
	while d:
		(root, par) = d.popleft()
		currhappy = h[root] + (maxcounts[root] - h[root]) // 2
		tothappy = 0
		for j in g[root]:
			if j != par:
				tothappy += h[j] + (maxcounts[j] - h[j]) // 2
		if tothappy > currhappy:
			ans = 0
			return
for _ in range(val()):
	(n, m) = li()
	p = [0] + li()
	h = [0] + li()
	g = defaultdict(set)
	su = sum(p)
	for _ in range(n - 1):
		(a, b) = li()
		g[a].add(b)
		g[b].add(a)
	ans = 1
	bfs()
	print('YES' if ans else 'NO')


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(n, m) = tuple((int(x) for x in input().split()))
	p = [int(x) for x in input().split()]
	h = [int(x) for x in input().split()]
	adj = [[] for i in range(n)]
	passby = [0] * n
	child = [[] for i in range(n)]
	for _a in range(n - 1):
		(c1, c2) = tuple((int(x) - 1 for x in input().split()))
		adj[c1].append(c2)
		adj[c2].append(c1)
	ans = 'YES'
	dfss = [0]
	vis = [-1 for i in range(n)]
	ha = [0 for i in range(n)]
	while len(dfss) > 0:
		curr = dfss[-1]
		cont = 1
		for i in adj[curr]:
			if vis[i] == -1:
				adj[i].remove(curr)
				dfss.append(i)
				cont = 0
				break
		if cont == 1:
			c = p[curr]
			for i in adj[curr]:
				c += vis[i]
			vis[curr] = c
			if (vis[curr] + h[curr]) % 2 == 1 or vis[curr] < h[curr]:
				ans = 'NO'
			ha[curr] = (vis[curr] + h[curr]) // 2
			hc = 0
			for j in adj[curr]:
				hc += ha[j]
			if ha[curr] < hc:
				ans = 'NO'
			dfss.pop(-1)
	print(ans)


import bisect
import collections
import copy
import enum
import functools
import heapq
import itertools
import math
import random
import re
import sys
import time
import string
from typing import List, Mapping
sys.setrecursionlimit(999999)
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	ps = list(map(int, input().split()))
	modes = list(map(int, input().split()))
	g = collections.defaultdict(list)
	for i in range(n - 1):
		(u, v) = map(int, input().split())
		g[u - 1].append(v - 1)
		g[v - 1].append(u - 1)

	def dfs(cur, far):
		b = True
		kg = 0
		cnt = 0
		for nc in g[cur]:
			if nc == far:
				continue
			(bn, gc, pc) = dfs(nc, cur)
			if not bn:
				return (False, 0, 0)
			else:
				kg += gc
				cnt += pc
		s = modes[cur]
		cnt += ps[cur]
		if s % 2 != cnt % 2:
			return (False, 0, 0)
		a = (s + cnt) // 2
		b = (cnt - s) // 2
		if a < 0 or b < 0:
			return (False, 0, 0)
		if a < kg:
			return (False, 0, 0)
		return (True, a, cnt)
	(b, _, _) = dfs(0, -1)
	if b:
		print('YES')
	else:
		print('NO')


import sys
input = sys.stdin.readline
T = int(input())
for _ in range(T):
	(n, m) = map(int, input().split())
	P = list(map(int, input().split()))
	H = list(map(int, input().split()))
	G = {}
	for i in range(1, n + 1):
		G[i] = []
	for i in range(n - 1):
		(x, y) = map(int, input().split())
		G[x].append(y)
		G[y].append(x)
	GY = [[] for i in range(n + 1)]
	vis = [0 for i in range(n + 1)]
	VO = [1]
	TP = [0 for i in range(n + 1)]
	A = [1]
	while len(A) != 0:
		a = A.pop()
		vis[a] = 1
		for i in G[a]:
			if vis[i] == 0:
				GY[a].append(i)
				vis[i] = 1
				A.append(i)
				VO.append(i)
	VO1 = VO[::-1]
	for i in VO1:
		TP[i] = P[i - 1]
		for j in GY[i]:
			TP[i] = TP[i] + TP[j]
	BV = [0 for i in range(n + 1)]
	flag = 0
	for i in VO:
		(x, m1) = (H[i - 1], TP[i])
		(G, B) = ((x + m1) // 2, (m1 - x) // 2)
		if (x + m1) % 2 != 0 or (x - m1) % 2 != 0 or G < 0 or (B < 0) or (G > m1) or (B > m1):
			flag = 1
			break
		BV[i] = G
	for i in VO1:
		v = 0
		for j in GY[i]:
			v = v + BV[j]
		lb = BV[i]
		if len(GY[i]) != 0 and v > lb:
			flag = 1
			break
	if flag == 1:
		print('NO')
	else:
		print('YES')


import threading
import sys
data = sys.stdin.read()
(*nums,) = map(int, data.split())
idx = -1

def inp():
	global idx
	idx += 1
	if idx < len(nums):
		return nums[idx]
	return -1

def dfs(g, p, h, n, v, par):
	total = p[v]
	total_happy = 0
	total_sad = 0
	for ch in g[v]:
		if ch != par:
			(is_ok, ch_happy, ch_sad, ch_total) = dfs(g, p, h, n, ch, v)
			total_happy += ch_happy
			total_sad += ch_sad
			total += ch_total
			if not is_ok:
				return (False, -1, -1, -1)
	happy = (total + h[v]) // 2
	if happy * 2 != total + h[v]:
		return (False, -1, -1, -1)
	sad = total - happy
	if len(g[v]) == 1 and g[v][0] == par or n == 1:
		if happy * 2 != p[v] + h[v] or happy < 0 or sad < 0:
			return (False, -1, -1, -1)
		return (True, happy, sad, total)
	if happy < 0 or sad < 0:
		return (False, -1, -1, -1)
	if sad > total_sad + p[v]:
		return (False, -1, -1, -1)
	return (True, happy, sad, total)

def solve(g, p, h, n):
	return dfs(g, p, h, n, 0, -1)[0]
sys.setrecursionlimit(100010)
ans = []

def main():
	global ans
	for _ in range(inp()):
		(n, _) = (inp(), inp())
		(*p,) = [inp() for _ in range(n)]
		(*h,) = [inp() for _ in range(n)]
		g = [[] for _ in range(n)]
		for _ in range(n - 1):
			(src, dst) = (inp(), inp())
			src -= 1
			dst -= 1
			g[src].append(dst)
			g[dst].append(src)
		try:
			ans.append('YES' if solve(g, p, h, n) else 'NO')
		except Exception as exc:
			print(exc)
try:
	t = threading.Thread(target=main)
	t.start()
	t.join()
except Exception as exc:
	print(repr(exc))
print('\n'.join(ans))


from collections import defaultdict, Counter
import threading
import sys

def ri():
	return int(input())

def rs():
	return input()

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

def rls():
	return list(input().split())
threading.stack_size(10 ** 8)
sys.setrecursionlimit(10 ** 6)

def main():
	for test in range(ri()):
		(n, m) = rl()
		p = [0] + rl()
		h = [0] + rl()
		g = defaultdict(list)
		for edge in range(n - 1):
			(u, v) = rl()
			g[u].append(v)
			g[v].append(u)
		tot = [0] * (n + 1)
		gg = [0] * (n + 1)
		global pos
		pos = True

		def dfs(cn, par):
			global pos
			tot[cn] = p[cn]
			sg = 0
			for nn in g[cn]:
				if nn != par:
					dfs(nn, cn)
					tot[cn] += tot[nn]
					sg += gg[nn]
			if tot[cn] + h[cn] & 1:
				pos = False
			gg[cn] = (tot[cn] + h[cn]) // 2
			if gg[cn] < 0 or gg[cn] > tot[cn] or sg > gg[cn]:
				pos = False
		dfs(1, -1)
		print(['NO', 'YES'][pos])
	pass
threading.Thread(target=main).start()


from collections import defaultdict
from sys import stdin, stdout, setrecursionlimit
setrecursionlimit(100000)
t = int(stdin.readline())
for _ in range(t):
	(n, m) = map(int, stdin.readline().split())
	p = [0] + list(map(int, stdin.readline().split()))
	h = [0] + list(map(int, stdin.readline().split()))
	adj = [[] for _ in range(n + 1)]
	for _ in range(n - 1):
		(u, v) = map(int, stdin.readline().split())
		adj[u].append(v)
		adj[v].append(u)
	cities = [(0, 0)] * (n + 1)
	visitors = [0] * (n + 1)
	seen = {1}

	def dfs(n):
		total = p[n]
		(ha, uh) = (0, 0)
		for nei in adj[n]:
			if nei not in seen:
				seen.add(nei)
				if not dfs(nei):
					return False
				ha += cities[nei][0]
				uh += cities[nei][1]
				total += visitors[nei]
		visitors[n] = total
		if abs(h[n]) > total:
			return False
		if (total + h[n]) % 2 == 1:
			return False
		ex_ha = (total + h[n]) // 2
		ex_uh = ex_ha - h[n]
		cities[n] = (ex_ha, ex_uh)
		if ex_ha < ha:
			return False
		return True
	if dfs(1):
		print('YES')
	else:
		print('NO')


import collections, sys, threading
sys.setrecursionlimit(10 ** 4)
threading.stack_size(32 * 1024)
from sys import stdin, stdout
from types import GeneratorType

def bootstrap(f, stack=[]):

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

def uncle_bogdan_and_country_happiness(n, m, p_a, h_a, xy_dic):
	ans = dfs(-1, 0, p_a, h_a, xy_dic)
	return ans[0]

@bootstrap
def dfs2(pcity, city, p_a, h_a, xy_dic):
	people = p_a[city]
	sub_bad_mood = 0
	sub_people = 0
	if city in xy_dic:
		for ncity in xy_dic[city]:
			if pcity != ncity:
				subans = (yield dfs(city, ncity, p_a, h_a, xy_dic))
				if not subans[0]:
					yield [False, None, None]
				sub_people += subans[1]
				sub_bad_mood += subans[2]
	people += sub_people
	bad_mood = (people - h_a[city]) // 2
	if (people - h_a[city]) % 2 == 1 or h_a[city] > people or bad_mood > sub_bad_mood + p_a[city]:
		yield [False, None, None]
	yield [True, people, bad_mood]

def dfs(pcity, city, p_a, h_a, xy_dic):
	people = p_a[city]
	sub_bad_mood = 0
	sub_people = 0
	if city in xy_dic:
		for ncity in xy_dic[city]:
			if pcity != ncity:
				subans = dfs(city, ncity, p_a, h_a, xy_dic)
				if not subans[0]:
					return [False, None, None]
				sub_people += subans[1]
				sub_bad_mood += subans[2]
	people += sub_people
	bad_mood = (people - h_a[city]) // 2
	if (people - h_a[city]) % 2 == 1 or h_a[city] > people or bad_mood > sub_bad_mood + p_a[city]:
		return [False, None, None]
	return [True, people, bad_mood]

def solve():
	t = int(stdin.readline())
	for i in range(t):
		(n, m) = map(int, stdin.readline().split())
		p_a = list(map(int, stdin.readline().split()))
		h_a = list(map(int, stdin.readline().split()))
		xy_dic = {}
		for _ in range(n - 1):
			(x, y) = map(int, stdin.readline().split())
			x -= 1
			y -= 1
			if x not in xy_dic:
				xy_dic[x] = []
			if y not in xy_dic:
				xy_dic[y] = []
			xy_dic[x].append(y)
			xy_dic[y].append(x)
		ans = uncle_bogdan_and_country_happiness(n, m, p_a, h_a, xy_dic)
		if ans:
			stdout.write('YES\n')
		else:
			stdout.write('NO\n')
threading.Thread(target=solve).start()


import sys
from collections import deque
sys.setrecursionlimit(300000)
input = sys.stdin.readline

def dfs(node, pre):
	sub[node] = p[node]
	s = 0
	for n in graph[node]:
		if n != pre:
			dfs(n, node)
			s += g[n]
			sub[node] += sub[n]
	if (sub[node] + h[node]) % 2 != 0:
		poo[0] = False
	g[node] = (sub[node] + h[node]) // 2
	if not (g[node] >= 0 and g[node] <= sub[node]):
		poo[0] = False
	if not s <= g[node]:
		poo[0] = False
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	p = [0] + list(map(int, input().split()))
	h = [0] + list(map(int, input().split()))
	graph = [[] for i in range(n + 1)]
	for i in range(n - 1):
		(a, b) = map(int, input().split())
		graph[a].append(b)
		graph[b].append(a)
	sub = [0 for i in range(n + 1)]
	g = [0 for i in range(n + 1)]
	poo = [True]
	dfs(1, -1)
	print('YES' if poo[0] else 'NO')


import io
import os
from collections import Counter, defaultdict, deque
from types import GeneratorType

def bootstrap(f, stack=[]):

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

def solve(N, M, P, H, edges):
	graph = [[] for i in range(N)]
	for (u, v) in edges:
		graph[u].append(v)
		graph[v].append(u)
	subTreePop = [0 for i in range(N)]

	@bootstrap
	def dfs(u, p):
		pop = P[u]
		for v in graph[u]:
			if v != p:
				yield dfs(v, u)
				pop += subTreePop[v]
		subTreePop[u] = pop
		yield
	assert sum(P) == M
	root = 0
	rootPop = dfs(root, -1)
	assert subTreePop[root] == M
	numGood = [0 for i in range(N)]
	numBad = [0 for i in range(N)]

	@bootstrap
	def dfs2(u, p):
		badTwo = subTreePop[u] - H[u]
		if badTwo % 2 != 0:
			yield False
		bad = badTwo // 2
		good = subTreePop[u] - bad
		if good < 0 or bad < 0:
			yield False
		numGood[u] = good
		numBad[u] = bad
		childrenGood = 0
		childrenBad = 0
		for v in graph[u]:
			if v != p:
				ok = (yield dfs2(v, u))
				if not ok:
					yield False
				childrenBad += numBad[v]
				childrenGood += numGood[v]
		if False:
			print('node', u, 'pop', subTreePop[u], 'good', good, 'bad', bad, 'cgood', childrenGood, 'cbad', childrenBad)
		if bad - P[u] > childrenBad:
			yield False
		yield True
	if dfs2(root, -1):
		return 'YES'
	return 'NO'
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
TC = int(input())
for tc in range(1, TC + 1):
	(N, M) = [int(x) for x in input().split()]
	P = [int(x) for x in input().split()]
	H = [int(x) for x in input().split()]
	edges = [[int(x) - 1 for x in input().split()] for i in range(N - 1)]
	ans = solve(N, M, P, H, edges)
	print(ans)


from sys import setrecursionlimit
setrecursionlimit(10 ** 9)
import threading
threading.stack_size(67108864)
g = []
p = []
h = []
a = []
mm = []
answer = True

def solution():
	global p, h, answer, a, mm
	answer = True
	(n, m) = map(int, input().split())
	p = list(map(int, input().split()))
	h = list(map(int, input().split()))
	g.clear()
	a.clear()
	mm.clear()
	for i in range(n):
		g.append([])
		a.append(0)
		mm.append(0)
	for i in range(n - 1):
		(v, to) = map(int, input().split())
		g[v - 1].append(to - 1)
		g[to - 1].append(v - 1)
	dfs(0, -1)
	if answer:
		print('YES')
	else:
		print('NO')

def dfs(v, parent):
	global answer, mm, a, p, h
	a[v] = p[v]
	sum_m = 0
	for to in g[v]:
		if to != parent:
			dfs(to, v)
			a[v] += a[to]
			sum_m += mm[to]
	mm[v] = (a[v] + h[v]) // 2
	if (a[v] + h[v]) % 2 == 0 and 0 <= mm[v] <= a[v] and (sum_m <= mm[v]):
		pass
	else:
		answer = False
t = int(input())
for _ in range(t):
	solution()


import sys
sys.setrecursionlimit(3 * 10 ** 5)

def dfs(x, pa):
	g = 0
	b = 0
	for nex in e[x]:
		if nex == pa:
			continue
		(ng, nb) = dfs(nex, x)
		g += ng
		b += nb
	c = p[x]
	num = h[x]
	if num % 2 != (c % 2 + (g - b) % 2) % 2:
		return (float('INF'), float('INF'))
	if num > g + b + c or num < g - b - c:
		return (float('INF'), float('INF'))
	now = g - b
	if num >= now:
		g += num - now
		g += (c - num + now) // 2
		b += (c - num + now) // 2
	else:
		b += now - num
		g += (c + num - now) // 2
		b += (c + num - now) // 2
	return (g, b)
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	p = list(map(int, input().split()))
	h = list(map(int, input().split()))
	e = [[] for i in range(n)]
	for i in range(n - 1):
		(a, b) = map(int, input().split())
		a -= 1
		b -= 1
		e[a].append(b)
		e[b].append(a)
	(g, b) = dfs(0, -1)
	if g >= 10 ** 15:
		print('NO')
	else:
		print('YES')


from collections import defaultdict
import sys
input = sys.stdin.buffer.readline
t = int(input())
for _ in range(t):
	(n, m) = [int(x) for x in input().split()]
	p = [int(x) for x in input().split()]
	p.insert(0, -1)
	h = [int(x) for x in input().split()]
	h.insert(0, -1)
	roads = defaultdict(list)
	for __ in range(n - 1):
		(x, y) = [int(x) for x in input().split()]
		roads[x].append(y)
		roads[y].append(x)
	parent = [-1 for zzz in range(n + 1)]
	depths = defaultdict(list)
	dfsStack = [[1, -1, 1]]
	maxDepth = 1
	leafs = set()
	while dfsStack:
		(node, par, d) = dfsStack.pop()
		depths[d].append(node)
		maxDepth = max(maxDepth, d)
		parent[node] = par
		children = [x for x in roads[node] if x != par]
		if len(children) == 0:
			leafs.add(node)
		for child in children:
			dfsStack.append([child, node, d + 1])
	passCityCnt = [0 for zzz in range(n + 1)]
	for d in range(maxDepth, 0, -1):
		for node in depths[d]:
			passCityCnt[node] += p[node]
			if node != 1:
				passCityCnt[parent[node]] += passCityCnt[node]
	happyCityCnt = [0 for zzz in range(n + 1)]
	ok = True
	for i in range(1, n + 1):
		if (passCityCnt[i] + h[i]) % 2 == 1:
			ok = False
			print('NO')
			break
		happyCityCnt[i] = (passCityCnt[i] + h[i]) // 2
		if happyCityCnt[i] < 0 or passCityCnt[i] - happyCityCnt[i] < 0:
			ok = False
			print('NO')
			break
	if ok == False:
		continue
	theoreticalMinHappiness = [0 for zzz in range(n + 1)]
	for d in range(maxDepth, 0, -1):
		for node in depths[d]:
			if node not in leafs and theoreticalMinHappiness[node] > happyCityCnt[node]:
				ok = False
				print('NO')
				break
			theoreticalMinHappiness[parent[node]] += happyCityCnt[node]
		if ok == False:
			break
	if ok == False:
		continue
	print('YES')


import sys, math
import io, os
from bisect import bisect_left as bl, bisect_right as br, insort
from heapq import heapify, heappush, heappop
from collections import defaultdict as dd, deque, Counter

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

def mdata():
	return list(map(int, data().split()))

def outl(var):
	sys.stdout.write('\n'.join(map(str, var)) + '\n')

def out(var):
	sys.stdout.write(str(var) + '\n')
from fractions import Fraction
INF = float('inf')
mod = int(1000000000.0) + 7

def dfs(graph, start=0):
	n = len(graph)
	dp = [0] * n
	(visited, finished) = ([False] * n, [False] * n)
	par = [0] * n
	stack = [start]
	while stack:
		start = stack[-1]
		if not visited[start]:
			visited[start] = True
			for child in graph[start]:
				if not visited[child]:
					stack.append(child)
					par[child] = start
		else:
			stack.pop()
			dp[start] += p[start]
			for child in graph[start]:
				if finished[child]:
					dp[start] += dp[child]
			finished[start] = True
	return dp

def dfs2(graph, start=0):
	n = len(graph)
	dp = [0] * n
	(visited, finished) = ([False] * n, [False] * n)
	n = [0] * n
	stack = [start]
	while stack:
		start = stack[-1]
		if not visited[start]:
			visited[start] = True
			for child in graph[start]:
				if not visited[child]:
					stack.append(child)
		else:
			stack.pop()
			dp[start] += (v[start] + h[start]) // 2
			a = v[start] - dp[start]
			if dp[start] - a != h[start] or a < 0:
				return False
			k = 0
			for child in graph[start]:
				if finished[child]:
					k += dp[child]
			if k > dp[start]:
				return False
			finished[start] = True
	return True
for t in range(int(data())):
	(n, m) = mdata()
	p = mdata()
	h = mdata()
	g = [[] for i in range(n)]
	for i in range(n - 1):
		(u, v) = mdata()
		(u, v) = (u - 1, v - 1)
		g[u].append(v)
		g[v].append(u)
	v = dfs(g, 0)
	if dfs2(g, 0):
		out('YES')
	else:
		out('NO')


from sys import setrecursionlimit
setrecursionlimit(10 ** 8)

def dfsp(p, prev):
	for i in child[p]:
		if i != prev:
			dfsp(i, p)
			a[p - 1] += a[i - 1]

def dfs(p, prev):
	global ans
	if abs(h[p - 1]) > a[p - 1]:
		ans = 'NO'
	if h[p - 1] + a[p - 1] & 1:
		ans = 'NO'
	good = (h[p - 1] + a[p - 1]) // 2
	cg = 0
	for i in child[p]:
		if i != prev:
			cg += dfs(i, p)
	if good < cg:
		ans = 'NO'
	return good
for T in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	h = list(map(int, input().split()))
	child = [[] for i in range(n + 1)]
	for i in range(n - 1):
		(u, v) = map(int, input().split())
		child[u].append(v)
		child[v].append(u)
	dfsp(1, -1)
	ans = 'YES'
	dfs(1, -1)
	print(ans)


import sys
input = sys.stdin.readline
t = int(input())
for ii in range(t):
	(n, m) = map(int, input().split())
	P = list(map(int, input().split()))
	H = list(map(int, input().split()))
	C = [list(map(int, input().split())) for i in range(n - 1)]
	for i in range(n - 1):
		for j in range(2):
			C[i][j] -= 1
	P = [[0, P[i]] for i in range(n)]
	V = [0] * n
	PA = [-1] * n
	M = [[] for i in range(n)]
	for i in range(n - 1):
		M[C[i][0]].append(C[i][1])
		M[C[i][1]].append(C[i][0])
	Q1 = []
	Q = [0]
	s = 0
	V[0] = 1
	while s < len(Q):
		i = Q[s]
		for x in M[i]:
			if V[x] == 0:
				V[x] = 1
				PA[x] = i
				Q.append(x)
		s += 1
	ng = 0
	s = 0
	C = [len(M[i]) for i in range(n)]
	C[0] += 1
	for i in range(n):
		if C[i] == 1:
			Q1.append(i)
	while s < len(Q1):
		i = Q1[s]
		V[i] = 1
		if P[i][0] - P[i][1] <= H[i] <= P[i][0] + P[i][1] and (H[i] - P[i][0] + P[i][1]) % 2 == 0:
			p0new = (H[i] - P[i][0] + P[i][1]) // 2 + P[i][0]
			P[i] = [p0new, sum(P[i]) - p0new]
			if i != 0:
				p = PA[i]
				P[p][0] += P[i][0]
				P[p][1] += P[i][1]
				C[p] -= 1
				if C[p] == 1:
					Q1.append(p)
					V[p] = 1
		else:
			ng = 1
			break
		s += 1
	if ng == 1:
		print('NO')
	else:
		print('YES')


from sys import stdin, stdout, setrecursionlimit
setrecursionlimit(100010)

class Graph:

	def __init__(self, No_of_nodes):
		self.n = No_of_nodes
		self.adj = [[] for i in range(self.n)]

	def addEdge(self, a, b):
		self.adj[a].append(b)

def dfs(start):
	visited[start] = True
	curr_pop = popu[start]
	hpop = 0
	for i in g.adj[start]:
		if visited[i]:
			continue
		child = dfs(i)
		if not child[2]:
			return [-1, -1, False]
		hpop += child[0]
		curr_pop += child[1]
	h = (curr_pop + happyidx[start]) // 2
	if (curr_pop + happyidx[start]) % 2 == 1 or h < 0 or curr_pop < h or (h < hpop):
		return [-1, -1, False]
	return [h, curr_pop, True]
fullans = ''
t = stdin.readline()
for _ in range(int(t)):
	(n, m) = map(int, stdin.readline().split())
	popu = list(map(int, stdin.readline().split()))
	happyidx = list(map(int, stdin.readline().split()))
	g = Graph(n)
	visited = [False] * n
	for i in range(n - 1):
		(x, y) = map(int, stdin.readline().split())
		g.addEdge(x - 1, y - 1)
		g.addEdge(y - 1, x - 1)
	ans = dfs(0)
	if ans[2]:
		stdout.write('YES\n')
	else:
		stdout.write('NO\n')
stdout.write(fullans)


import sys
input = sys.stdin.readline
T = int(input())
for testcase in range(1, T + 1):
	(n, m) = map(int, input().split())
	p = tuple(map(int, input().split()))
	h = tuple(map(int, input().split()))
	a = [0] * n
	b = [0] * n
	edge = [[] for i in range(n)]
	for _ in range(n - 1):
		(x, y) = map(int, input().split())
		edge[x - 1].append(y - 1)
		edge[y - 1].append(x - 1)
	par = [-1] * n
	tank = [0]
	order = []
	while tank:
		now = tank.pop()
		order.append(now)
		for e in edge[now]:
			if par[now] != e:
				par[e] = now
				tank.append(e)
	flag = True
	for e in order[::-1]:
		if a[e] - b[e] - p[e] <= h[e] <= a[e] + b[e] + p[e] and (h[e] + a[e] + b[e] + p[e]) % 2 == 0:
			if e != 0:
				a[par[e]] += (h[e] + a[e] + b[e] + p[e]) // 2
				b[par[e]] += (h[e] + a[e] + b[e] + p[e]) // 2 - h[e]
		else:
			flag = False
			break
	if flag:
		print('YES')
	else:
		print('NO')


import sys
import math
from collections import defaultdict, Counter, deque
sys.setrecursionlimit(10 ** 5)
input = sys.stdin.readline

def print(x):
	sys.stdout.write(str(x) + '\n')
from types import GeneratorType

def bootstrap(f, stack=[]):

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

def add(a, b):
	l[a].append(b)
	l[b].append(a)

@bootstrap
def find(u, v):
	a[u] = p[u - 1]
	sumg = 0
	for j in l[u]:
		if j != v:
			x = (yield find(j, u))
			if x == 1:
				yield 1
			a[u] += a[j]
			sumg += g[j]
	if (a[u] + h[u - 1]) % 2 != 0:
		yield 1
	g[u] = (a[u] + h[u - 1]) // 2
	if g[u] < 0 or g[u] > a[u]:
		yield 1
	if sumg > g[u]:
		yield 1
	yield 0
t = int(input())
for i in range(t):
	l = defaultdict(list)
	(n, m) = map(int, input().split())
	p = list(map(int, input().split()))
	h = list(map(int, input().split()))
	for j in range(n - 1):
		(x, y) = map(int, input().split())
		add(x, y)
	g = [0] * (n + 1)
	a = [0] * (n + 1)
	flag = find(1, 0)
	if flag == 0:
		print('YES')
	else:
		print('NO')


import sys

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

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

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

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

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

def wia(a, sep=' '):
	sys.stdout.write(sep.join([str(x) for x in a]))
	sys.stdout.write('\n')
from collections import deque

def toposort(graph):
	(res, found) = ([], [0] * len(graph))
	stack = list(range(len(graph)))
	while stack:
		node = stack.pop()
		if node < 0:
			res.append(~node)
		elif not found[node]:
			found[node] = 1
			stack.append(~node)
			stack += graph[node]
	for node in res:
		if any((found[nei] for nei in graph[node])):
			return None
		found[node] = 0
	return res[::-1]

def solve(n, m, p, h, e):
	order = []
	pre = [-1] * n
	visited = [False] * n
	q = deque([0])
	while q:
		v = q.popleft()
		order.append(v)
		visited[v] = True
		for w in e[v]:
			if not visited[w]:
				q.append(w)
				pre[w] = v
	past = [0] * n
	bvs = [0] * n
	for v in reversed(order):
		past[v] = p[v]
		for w in e[v]:
			if w == pre[v]:
				continue
			past[v] += past[w]
		mv = past[v]
		gv = (mv + h[v]) / 2
		bv = (mv - h[v]) / 2
		if gv < 0 or bv < 0 or int(gv) != gv or (int(bv) != bv):
			ws('NO')
			return
		bvs[v] = int(bv)
		cnt = 0
		for w in e[v]:
			if w == pre[v]:
				continue
			cnt += bvs[w]
		if cnt < bvs[v] - p[v]:
			ws('NO')
			return
		if v == 0 and mv != m:
			ws('NO')
			return
	ws('YES')

def main():
	for _ in range(ri()):
		(n, m) = ria()
		p = ria()
		h = ria()
		e = [[] for i in range(n)]
		for i in range(n - 1):
			(x, y) = ria()
			x -= 1
			y -= 1
			e[x].append(y)
			e[y].append(x)
		solve(n, m, p, h, e)
main()


import os, sys
from io import BytesIO, IOBase
from collections import defaultdict

def main():
	for _ in range(int(input())):
		(n, m) = map(int, input().split())
		people = list(map(int, input().split()))
		happ = list(map(int, input().split()))
		path = defaultdict(set)
		path1 = defaultdict(set)
		for _ in range(n - 1):
			(x, y) = map(int, input().split())
			path[x].add(y)
			path1[x].add(y)
			path[y].add(x)
			path1[y].add(x)
		tot_people = people[:]
		st = [1]
		while len(st):
			x = st[-1]
			if not len(path1[x]):
				st.pop()
				if len(st):
					tot_people[st[-1] - 1] += tot_people[x - 1]
				continue
			st.append(path1[x].pop())
			path1[st[-1]].remove(x)
			path[st[-1]].remove(x)
		ans = 'YES'
		for i in range(1, n + 1):
			if not -tot_people[i - 1] <= happ[i - 1] <= tot_people[i - 1] or not happ[i - 1] % 2 == tot_people[i - 1] % 2:
				ans = 'NO'
				break
			cul = 0
			for a in path[i]:
				cul += happ[a - 1]
			if cul > happ[i - 1] + people[i - 1] and len(path[i]):
				ans = 'NO'
				break
		print(ans)
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()


import sys

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

def dfs(tree, h, p, i, parent):
	cgood = 0
	flag = True
	for j in tree[i]:
		if j != parent:
			(x, y, z) = dfs(tree, h, p, j, i)
			p[i] += x
			cgood += y
			flag &= z
	good = (p[i] + h[i]) // 2
	bad = p[i] - good
	if (p[i] + h[i]) % 2 == 1 or good < cgood or good < 0 or (bad < 0):
		flag = False
	return (p[i], good, flag)

def solve():
	t = int(input())
	while t > 0:
		(n, m) = put()
		(p, h) = (put(), put())
		tree = [[] for i in range(n)]
		for _ in range(n - 1):
			(x, y) = put()
			tree[x - 1].append(y - 1)
			tree[y - 1].append(x - 1)
		(a, _, c) = dfs(tree, h, p, 0, -1)
		if a != m or not c:
			print('NO')
		else:
			print('YES')
		t -= 1
recur = 10 ** 5 * 2 + 1000
sys.setrecursionlimit(recur)
solve()


import threading
import sys
input = sys.stdin.buffer.readline
from types import GeneratorType

def bootstrap(f, stack=[]):

	def wrappedfunc(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		else:
			to = f(*args, **kwargs)
			while True:
				if type(to) is GeneratorType:
					stack.append(to)
					to = next(to)
				else:
					stack.pop()
					if not stack:
						break
					to = stack[-1].send(to)
			return to
	return wrappedfunc
t = int(input())
for zzz in range(t):
	(n, m) = [int(x) for x in input().split()]
	p = [int(x) for x in input().split()]
	h = [int(x) for x in input().split()]
	p.insert(0, 0)
	h.insert(0, 0)
	edges = [[] for _ in range(n + 1)]

	def readIntoEdges(number):
		for zz in range(number):
			(u, v) = [int(x) for x in input().split()]
			edges[u].append(v)
			edges[v].append(u)
	if n >= 10000:
		total = n - 1
		numbers = [total // 10 for _ in range(9)]
		numbers.append(total - total // 10 * 9)
		threads = []
		for x in numbers:
			threads.append(threading.Thread(target=readIntoEdges, args=(x,)))
		for t in threads:
			t.start()
		for t in threads:
			t.join()
	else:
		readIntoEdges(n - 1)
	ok = [True]

	@bootstrap
	def dfs(node, parent):
		T = p[node]
		minH = 0
		for nextt in edges[node]:
			if nextt != parent:
				(a, b) = (yield dfs(nextt, node))
				T += a
				minH += b
		temp = h[node] + T
		if temp % 2 == 1:
			ok[0] = False
		actualH = temp // 2
		actualS = T - actualH
		if actualH < 0 or actualS < 0:
			ok[0] = False
		if actualH < minH:
			ok[0] = False
		yield (T, actualH)
		yield None
	dfs(1, 0)
	if ok[0]:
		print('YES')
	else:
		print('NO')


from sys import stdin
input = lambda : stdin.readline().strip()
from math import ceil, sqrt, factorial, gcd

def dfs():
	stack = [[0, 0]]
	while stack:
		x = stack.pop()
		for i in graph[x[0]]:
			papa[i] = x[0]
			graph[i].remove(x[0])
			stack.append([i, x[1] + 1])
		leaves[x[1]].append(x[0])
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	per = list(map(int, input().split()))
	h = list(map(int, input().split()))
	graph = {i: set() for i in range(n)}
	papa = [0, 0]
	happ = [0, 0]
	for i in range(n - 1):
		(a, b) = map(int, input().split())
		graph[a - 1].add(b - 1)
		graph[b - 1].add(a - 1)
		papa.append(0)
		happ.append(0)
	leaves = [[] for i in range(n)]
	dfs()
	flag = 'YES'
	for i in range(n - 1, -1, -1):
		for k in leaves[i]:
			if per[k] < 0:
				flag = 'NO'
				break
			if -1 * per[k] <= h[k] <= per[k]:
				if per[k] % 2 == abs(h[k]) % 2:
					x = (per[k] + h[k]) // 2
					y = per[k] - x
					if x < happ[k]:
						flag = 'NO'
						break
					per[papa[k]] += per[k]
					happ[papa[k]] += x
				else:
					flag = 'NO'
					break
			else:
				flag = 'NO'
		if flag == 'NO':
			break
	print(flag)


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')
sys.setrecursionlimit(3 * 10 ** 5)

def dfs(u):
	if v[u] == 1:
		return [0, 0]
	else:
		v[u] = 1
		bad = 0
		total = 0
		for j in adj[u]:
			if v[j] == 0:
				k = dfs(j)
				if k == [-1, -1]:
					return [-1, -1]
				bad += k[1]
				total += k[0]
		total += p[u - 1]
		if total > m:
			return [-1, -1]
		if (total - h[u - 1]) % 2 != 0:
			return [-1, -1]
		ubad = (total - h[u - 1]) // 2
		if ubad < 0:
			return [-1, -1]
		if ubad - p[u - 1] > bad:
			return [-1, -1]
		return [total, ubad]
t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	p = list(map(int, input().split()))
	h = list(map(int, input().split()))
	adj = [[] for j in range(n + 1)]
	for j in range(n - 1):
		(x, y) = map(int, input().split())
		adj[x].append(y)
		adj[y].append(x)
	v = [0] * (n + 1)
	p = dfs(1)
	if p != [-1, -1]:
		print('YES')
	else:
		print('NO')


import os
import sys
from io import BytesIO, IOBase
import heapq as h
from bisect import bisect_left, bisect_right
from types import GeneratorType
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		import os
		self.os = os
		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 = self.os.read(self._fd, max(self.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 = self.os.read(self._fd, max(self.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:
			self.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')
import time
start_time = time.time()
import collections as col
import math, string
from functools import reduce

def getInts():
	return [int(s) for s in input().split()]

def getInt():
	return int(input())

def getStrs():
	return [s for s in input().split()]

def getStr():
	return input()

def listStr():
	return list(input())
MOD = 10 ** 9 + 7

def bootstrap(f, stack=[]):

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

def solve():
	(N, M) = getInts()
	P = getInts()
	H = getInts()
	dp = [0 for i in range(N)]
	parents = [-1 for i in range(N)]
	children = col.defaultdict(set)
	graph = col.defaultdict(set)
	for n in range(N - 1):
		(U, V) = getInts()
		U -= 1
		V -= 1
		graph[U].add(V)
		graph[V].add(U)
	visited = set()

	@bootstrap
	def dfs(node):
		dp[node] = P[node]
		if node not in visited:
			visited.add(node)
		for neighbour in graph[node]:
			if neighbour != parents[node]:
				parents[neighbour] = node
				children[node].add(neighbour)
				yield dfs(neighbour)
				dp[node] += dp[neighbour]
		yield
	dfs(0)
	if H[0] > dp[0] or H[0] < -dp[0] or H[0] % 2 != dp[0] % 2:
		return 'NO'
	for i in range(1, N):
		max_happiness = min(dp[i], H[parents[i]] + dp[parents[i]] - dp[i])
		min_happiness = -dp[i]
		if H[i] < min_happiness or H[i] > max_happiness or H[i] % 2 != dp[i] % 2:
			return 'NO'
	for parent in children:
		p_h = H[parent]
		p_people = dp[parent]
		c_h = 0
		c_people = 0
		for child in children[parent]:
			c_h += H[child]
			c_people += dp[child]
		if c_h > p_h + p_people - c_people:
			return 'NO'
	return 'YES'
for _ in range(getInt()):
	print(solve())


from sys import setrecursionlimit
from collections import defaultdict
setrecursionlimit(10 ** 8)
data = True

class Graph:

	def __init__(self):
		self.g = defaultdict(list)
		self.p = []
		self.h = []
		self.a = []

	def addEdge(self, u, v):
		self.g[u].append(v)
		self.g[v].append(u)

	def dfs(self, v, ancestor=-1):
		global data
		self.a[v] = self.p[v]
		summ = 0
		for to in self.g[v]:
			if to == ancestor:
				continue
			self.dfs(to, v)
			summ += self.g[to]
			self.a[v] += self.a[to]
		if (self.a[v] + self.h[v]) % 2 != 0:
			data = False
		self.g[v] = (self.a[v] + self.h[v]) // 2
		if not (self.g[v] >= 0 and self.g[v] <= self.a[v]):
			data = False
		if summ > self.g[v]:
			data = False

def main():
	global data
	T = int(input())
	for _ in range(T):
		(N, M) = map(int, input().split())
		gr = Graph()
		gr.p = list(map(int, input().split()))
		gr.h = list(map(int, input().split()))
		gr.a = [0] * N
		for _ in range(N - 1):
			(u, v) = map(int, input().split())
			gr.addEdge(u - 1, v - 1)
		gr.dfs(0)
		if data == True:
			print('YES')
		else:
			print('NO')
		data = True
main()


from collections import deque
import sys
input = sys.stdin.buffer.readline
t = 1
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	p = list(map(int, input().split()))
	h = list(map(int, input().split()))
	edge = [[] for i in range(n)]
	for i in range(n - 1):
		(u, v) = map(int, input().split())
		edge[u - 1].append(v - 1)
		edge[v - 1].append(u - 1)
	deq = deque([(0, -1)])
	res = []
	parent = [-1 for i in range(n)]
	while deq:
		(v, pv) = deq.popleft()
		res.append(v)
		parent[v] = pv
		for nv in edge[v]:
			if nv != pv:
				deq.append((nv, v))
	res = res[::-1]
	passer = [p[i] for i in range(n)]
	unh = [0 for i in range(n)]
	check = True
	for v in res:
		for nv in edge[v]:
			if nv != parent[v]:
				passer[v] += passer[nv]
		if passer[v] % 2 != h[v] % 2 or h[v] > passer[v] or h[v] < -passer[v]:
			check = False
		else:
			unh[v] = (passer[v] - h[v]) // 2
	if not check:
		print('NO')
		continue
	ans = True
	for v in res:
		temp = 0
		c = False
		for nv in edge[v]:
			if nv != parent[v]:
				temp += unh[nv]
				c = True
		if c:
			ans &= max(unh[v] - p[v], 0) <= temp
	if ans:
		print('YES')
	else:
		print('NO')


from sys import stdin, stdout

def input():
	return stdin.readline().strip()
tests = int(input())
for t in range(tests):
	(n, m) = list(map(int, input().split()))
	citizens = [None] + list(map(int, input().split()))
	happiness = [None] + list(map(int, input().split()))
	check = True
	city_dict = {}
	for i in range(n - 1):
		(c, p) = list(map(int, input().split()))
		if c not in city_dict:
			city_dict[c] = set([p])
		else:
			city_dict[c].add(p)
		if p not in city_dict:
			city_dict[p] = set([c])
		else:
			city_dict[p].add(c)
	visited_arr = [0 for i in range(n + 1)]
	stack = [[1, citizens[1], 0]]
	while stack and check:
		cont = True
		curr = stack[-1][0]
		visited_arr[curr] = 1
		if curr in city_dict:
			for city in list(city_dict[curr]):
				if visited_arr[city] == 0:
					stack.append([city, citizens[city], 0])
					cont = False
					city_dict[curr].remove(city)
					break
				else:
					city_dict[curr].remove(city)
		if cont:
			arr = stack.pop()
			pop = arr[1]
			sum_h_pop = arr[2]
			if (pop + happiness[curr]) % 2 != 0:
				check = False
			h_pop = int((pop + happiness[curr]) / 2)
			if h_pop - sum_h_pop < 0:
				check = False
			if not (h_pop >= 0 and h_pop <= pop):
				check = False
			if len(stack) > 0:
				stack[-1][1] += pop
				stack[-1][2] += h_pop
	if check:
		print('YES')
	else:
		print('NO')


import sys
from collections import deque
input = sys.stdin.buffer.readline
T = int(input())
for _ in range(T):
	(n, m) = map(int, input().split())
	p = list(map(int, input().split()))
	h = list(map(int, input().split()))
	e = [[] for _ in range(n)]
	for _ in range(n - 1):
		(a, b) = map(int, input().split())
		e[a - 1].append(b - 1)
		e[b - 1].append(a - 1)
	(par, order) = ([0] * n, [])
	q = deque([0])
	while q:
		u = q.popleft()
		order.append(u)
		for v in e[u]:
			if v == par[u]:
				continue
			par[v] = u
			q.append(v)
	(ok, hc, bc) = (True, [0] * n, [0] * n)
	for u in reversed(order):
		(hcc, bcc) = (0, 0)
		for v in e[u]:
			if v == par[u]:
				continue
			hcc += hc[v]
			bcc += bc[v]
		bcc += p[u]
		(tt, thc, tbc, d) = (hcc + bcc, 0, 0, abs(h[u]))
		if h[u] >= 0:
			thc = d
		else:
			tbc = d
		if d > tt or (tt - d) % 2:
			ok = False
			break
		thc += (tt - d) // 2
		tbc += (tt - d) // 2
		if tbc > bcc:
			ok = False
			break
		(hc[u], bc[u]) = (thc, tbc)
	print('YES' if ok else 'NO')


t = int(input())
from sys import setrecursionlimit
setrecursionlimit(10 ** 6)
while t:
	(n, m) = [int(i) for i in input().split()]
	p = [int(i) for i in input().split()]
	h = [int(i) for i in input().split()]
	adj = {i: [] for i in range(1, n + 1)}
	for i in range(n - 1):
		(u, v) = [int(i) for i in input().split()]
		adj[u].append(v)
		adj[v].append(u)

	def dfs(node, par):
		passers = 0
		new_h = h[node - 1]
		for c in adj[node]:
			if c == par:
				continue
			(tot, b) = dfs(c, node)
			new_h -= h[c - 1]
			passers += tot
			if not b:
				return (0, False)
		if (passers + p[node - 1] - h[node - 1]) % 2 == 0 and h[node - 1] <= passers + p[node - 1] and (h[node - 1] >= -1 * (passers + p[node - 1])):
			if (p[node - 1] - new_h) % 2 == 0 and new_h >= -1 * p[node - 1]:
				return (passers + p[node - 1], True)
			else:
				return (passers, False)
		return (passers, False)
	(_, ans) = dfs(1, -1)
	if ans:
		print('YES')
	else:
		print('NO')
	t -= 1


from sys import setrecursionlimit
setrecursionlimit(10 ** 6)

def dfs(node, par):
	global bad
	a[node] = p[node]
	g_sum = 0
	for i in graph[node]:
		if i == par:
			continue
		dfs(i, node)
		a[node] += a[i]
		g_sum += g[i]
	if a[node] + h[node] & 1:
		bad = True
	g[node] = (a[node] + h[node]) // 2
	if g[node] > a[node] or g[node] < 0:
		bad = True
	if g_sum > g[node]:
		bad = True
bad = False
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	(p, h) = [list(map(int, input().split())) for i in range(2)]
	bad = False
	graph = [[] for i in range(n)]
	for i in range(n - 1):
		(u, v) = map(int, input().split())
		u -= 1
		v -= 1
		graph[u].append(v)
		graph[v].append(u)
	(a, g) = ([0] * n, [0] * n)
	dfs(0, -1)
	print('NO' if bad else 'YES')


import sys
input = sys.stdin.readline
for f in range(int(input())):
	(n, m) = map(int, input().split())
	p = list(map(int, input().split()))
	h = list(map(int, input().split()))
	neig = [0] * n
	for i in range(n):
		neig[i] = [0]
	for i in range(n - 1):
		(vertexa, vertexb) = map(int, input().split())
		vertexa -= 1
		vertexb -= 1
		neig[vertexa][0] += 1
		neig[vertexb][0] += 1
		neig[vertexa].append(vertexb)
		neig[vertexb].append(vertexa)
	people = [0] * n
	sadpeople = [0] * n
	tod = []
	for i in range(n):
		if neig[i][0] == 1 and i != 0:
			tod.append(i)
	poss = True
	while len(tod) > 0:
		city = tod.pop()
		people[city] += p[city]
		pip = people[city] - h[city]
		if pip % 2 != 0:
			poss = False
		sad = pip // 2
		if sad > sadpeople[city] + p[city]:
			poss = False
		if sad > people[city]:
			poss = False
		if sad < 0:
			poss = False
		neig[city][0] = 0
		for i in range(1, len(neig[city])):
			if neig[neig[city][i]][0] > 0:
				city2 = neig[city][i]
				people[city2] += people[city]
				sadpeople[city2] += sad
				neig[city2][0] -= 1
				if neig[city2][0] == 1 and city2 != 0:
					tod.append(city2)
	people[0] += p[0]
	pip = people[0] - h[0]
	if pip % 2 != 0:
		poss = False
	sad = pip // 2
	if sad > sadpeople[0] + p[0]:
		poss = False
	if sad > people[0]:
		poss = False
	if sad < 0:
		poss = False
	if poss:
		print('YES')
	else:
		print('NO')


def tree(d, parent):
	if len(d[parent]) == 0:
		return
	for i in d[parent]:
		d[i].remove(parent)
	for i in d[parent]:
		parent = i
		tree(d, parent)

def check_happy(d, h, p):
	for i in range(1, n + 1):
		if (p[i - 1] - h[i - 1]) % 2 != 0 or abs(h[i - 1]) > p[i - 1]:
			return 1
		if len(d[i]) == 0:
			continue
		val = 0
		pval = 0
		for j in d[i]:
			val += h[j - 1]
			pval += p[j - 1]
		if val + pval > h[i - 1] + p[i - 1]:
			return 1
	return 0

def fix(d, p, node):
	if len(d[node]) == 0:
		return p[node - 1]
	val = p[node - 1]
	for i in d[node]:
		val += fix(d, p, i)
	p[node - 1] = val
	return val
t = int(input())
for _ in range(t):
	try:
		(n, m) = map(int, input().split())
		p = list(map(int, input().split()))
		h = list(map(int, input().split()))
		d = {}
		for i in range(1, n + 1):
			d[i] = []
		for i in range(n - 1):
			(a, b) = map(int, input().split())
			d[a].append(b)
			d[b].append(a)
		tree(d, 1)
		fix(d, p, 1)
		x = check_happy(d, h, p)
		if x:
			print('NO')
			continue
		print('YES')
	except:
		print('YES')


from __future__ import division, print_function
import os, 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 ii():
	return int(input())

def si():
	return input()

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

def msi():
	return map(str, input().strip().split(' '))

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

def dmain():
	sys.setrecursionlimit(1000000)
	threading.stack_size(1024000)
	thread = threading.Thread(target=main)
	thread.start()
abc = 'abcdefghijklmnopqrstuvwxyz'
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}
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u', 'y']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def getKey(item):
	return item[1]

def sort2(l):
	return sorted(l, key=getKey, reverse=True)

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 ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def ceil(x, y):
	if x % y == 0:
		return x // y
	else:
		return x // y + 1

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 read():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def main():
	import sys
	input = sys.stdin.buffer.readline
	sys.setrecursionlimit(10 ** 6)
	I = lambda : list(map(int, input().split()))
	for tc in range(int(input())):
		(n, m) = I()
		p = I()
		h = I()
		g = [[] for i in range(n)]
		ans = 'YES'
		for i in range(n - 1):
			(u, v) = I()
			g[u - 1].append(v - 1)
			g[v - 1].append(u - 1)
		c = [0] * n

		def dfs(v, pa):
			d = 0
			for i in g[v]:
				if i != pa:
					d += dfs(i, v)
			c[v] = d + p[v]
			return c[v]
		dfs(0, -1)

		def df(v, pa):
			d = h[v]
			cr = c[v]
			bd = (cr - h[v]) // 2
			gd = cr - bd
			pos = 1
			aa = 0
			bb = 0
			for i in g[v]:
				if i != pa:
					kk = c[i]
					bh = (c[i] - h[i]) // 2
					gh = c[i] - bh
					aa += gh
					bb += bh
					pos = min(pos, df(i, v))
			if c[v] < abs(h[v]) or (cr - h[v]) % 2:
				return 0
			if aa <= gd and bb <= bd + (gd - aa):
				return pos
			return 0
		po = df(0, -1)
		if not po:
			ans = 'NO'
		print(ans)
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')
main()


import sys
input = sys.stdin.buffer.readline
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	pr = list(map(int, input().split()))
	hr = list(map(int, input().split()))
	dic = {}
	dis = {}
	people = {}
	for i in range(1, n + 1):
		dic[i] = []
		dis[i] = 0
		people[i] = -1
	for i in range(n - 1):
		(x, y) = map(int, input().split())
		dic[x].append(y)
		dic[y].append(x)
	dico = {}
	for i in dic:
		dico[i] = dic[i].copy()
	dis[1] = 0
	level = 1
	se = {1}
	ne = set({1})
	while ne:
		tem = set({})
		for i in ne:
			xx = dic[i]
			for j in xx:
				if not j in se:
					se.add(j)
					dis[j] = level
					tem.add(j)
		ne = tem.copy()
		level += 1
	for i in dic:
		dic[i].sort(key=lambda x: dis[x])
	st = 1
	se = {1}
	people[1] = pr[0]
	while dic[st]:
		ne = dic[st].pop()
		if not ne in se:
			people[ne] = 0
			se.add(ne)
			people[ne] += pr[ne - 1]
		else:
			people[ne] += people[st]
		st = ne
	flag = True
	numb = {}
	for i in range(1, n + 1):
		plu = people[i]
		minu = hr[i - 1]
		if (plu + minu) % 2 != 0:
			flag = False
			break
		xx = (plu + minu) // 2
		yy = plu - xx
		if xx < 0 or yy < 0:
			flag = False
			break
		else:
			numb[i] = [xx, yy]
	if flag:
		se = {1}
		ne = set({1})
		while ne:
			tem = set({})
			for i in ne:
				xx = dico[i]
				happ = 0
				sad = 0
				for j in xx:
					if not j in se:
						se.add(j)
						tem.add(j)
						happ += numb[j][0]
						sad += numb[j][1]
				if happ > numb[i][0] or happ + sad != numb[i][0] + numb[i][1] - pr[i - 1]:
					flag = False
			ne = tem.copy()
	if flag:
		print('YES')
	else:
		print('NO')


from types import GeneratorType

def bootstrap(f, stack=[]):

	def wrappedfunc(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		else:
			to = f(*args, **kwargs)
			while True:
				if type(to) is GeneratorType:
					stack.append(to)
					to = next(to)
				else:
					stack.pop()
					if not stack:
						break
					to = stack[-1].send(to)
			return to
	return wrappedfunc
access = True
(n, m, p, h, capital, edges, a, g) = [None] * 8

def take_input():
	global access, n, m, p, h, capital, edges, a, g
	(n, m) = list(map(int, input().split()))
	p = list(map(int, input().split()))
	h = list(map(int, input().split()))
	edges = [[] for i in range(n)]
	for i in range(n - 1):
		(x, y) = list(map(int, input().split()))
		x -= 1
		y -= 1
		edges[x].append(y)
		edges[y].append(x)

@bootstrap
def dfs(u, ancestor):
	global access, n, m, p, h, capital, edges, a, g
	a[u] = p[u]
	sum_g = 0
	for v in edges[u]:
		if v == ancestor:
			continue
		yield dfs(v, u)
		sum_g += g[v]
		a[u] += a[v]
	if not (a[u] + h[u]) % 2 == 0:
		access = False
	g[u] = (a[u] + h[u]) // 2
	if not (g[u] >= 0 and g[u] <= a[u]):
		access = False
	if not sum_g <= g[u]:
		access = False
	yield

def solve():
	global access, n, m, p, h, capital, edges, a, g
	a = [None] * n
	g = [0] * n
	NIL = -1
	capital = 0
	access = True
	dfs(capital, NIL)
	print('YES' if access else 'NO')

def main():
	T = int(input().strip())
	for case in range(T):
		take_input()
		solve()
main()


import sys
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 MI1():
	return map(int1, 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]
for _ in range(II()):
	ng = False
	(n, m) = MI()
	to = [[] for _ in range(n)]
	pp = LI()
	hh = LI()
	for _ in range(n - 1):
		(u, v) = MI1()
		to[u].append(v)
		to[v].append(u)
	dp = [[-1, 0] for _ in range(n)]
	stack = [(0, -1)]
	while stack:
		(u, pu) = stack.pop()
		if dp[u][0] == -1:
			dp[u][0] = 0
			stack.append((u, pu))
			for v in to[u]:
				if v == pu:
					continue
				stack.append((v, u))
		else:
			res = [0, 0]
			for v in to[u]:
				if v == pu:
					continue
				res[0] += dp[v][0]
				res[1] += dp[v][1]
			p = sum(res) + pp[u]
			bad = (p - hh[u]) // 2
			if p % 2 != hh[u] % 2:
				ng = True
				break
			if bad > pp[u] + res[1] or bad < 0:
				ng = True
				break
			dp[u] = [p - bad, bad]
	if ng:
		print('NO')
	else:
		print('YES')


import sys
input = sys.stdin.readline

def F():
	stack = [1]
	vs = set([1])
	vs_dfs = list()
	while stack:
		v = stack.pop()
		vs_dfs.append(v)
		for u in d[v]:
			if u in vs:
				continue
			G[v].add(u)
			vs.add(u)
			stack.append(u)
	for v in vs_dfs[::-1]:
		for u in G[v]:
			P[v] += P[u]
		if (P[v] + H[v]) % 2:
			return False
		(p, n) = ((P[v] + H[v]) // 2, (P[v] - H[v]) // 2)
		if p < 0 or n < 0:
			return False
		pp = 0
		for u in G[v]:
			(p2, n2) = ((P[u] + H[u]) // 2, (P[u] - H[u]) // 2)
			pp += p2
		if p < pp:
			return False
	return True
(T,) = map(int, input().split())
for _ in range(T):
	(N, M) = map(int, input().split())
	P = [0] + list(map(int, input().split()))
	H = [0] + list(map(int, input().split()))
	d = [set() for _ in range(N + 1)]
	G = [set() for _ in range(N + 1)]
	for _ in range(N - 1):
		(a, b) = map(int, input().split())
		d[a].add(b)
		d[b].add(a)
	if F():
		print('YES')
	else:
		print('NO')


from collections import defaultdict
from sys import stdin, stdout, setrecursionlimit
setrecursionlimit(10 ** 6)
valid = True

def dfs(v, parent):
	global valid
	tot[v] = people[v]
	sum_g = 0
	for adj in graph[v]:
		if adj != parent:
			dfs(adj, v)
			tot[v] = tot[v] + tot[adj]
			sum_g = sum_g + g[adj]
	if (tot[v] + happiness[v]) % 2 != 0:
		valid = False
	g[v] = (happiness[v] + tot[v]) // 2
	if g[v] < 0 or g[v] > tot[v]:
		valid = False
	if sum_g > g[v]:
		valid = False
t = int(input())
for _ in range(t):
	tot = {}
	g = {}
	valid = True
	(n, m) = map(int, input().split())
	graph = [[] for _ in range(n + 1)]
	people = [int(i) for i in input().split()]
	happiness = [int(j) for j in input().split()]
	for _ in range(n - 1):
		(a, b) = map(int, input().split())
		graph[a - 1].append(b - 1)
		graph[b - 1].append(a - 1)
	dfs(0, -1)
	if valid == False:
		print('NO')
	else:
		print('YES')


import sys
sys.setrecursionlimit(1000000)

def dfs(x, par):
	global f
	tot[x] = p[x]
	sumgd = 0
	for v in g[x]:
		if v != par:
			dfs(v, x)
			tot[x] += tot[v]
			sumgd += gd[v]
	if (tot[x] + h[x]) % 2 == 1:
		f = 1
	gd[x] = (tot[x] + h[x]) // 2
	if gd[x] < 0 or gd[x] > tot[x]:
		f = 1
	if sumgd > gd[x]:
		f = 1
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	p = [-1] + list(map(int, input().split()))
	h = [-1] + list(map(int, input().split()))
	g = [[] for i in range(n + 1)]
	f = 0
	for i in range(n - 1):
		(x, y) = map(int, input().split())
		g[x].append(y)
		g[y].append(x)
	tot = [0] * (n + 1)
	gd = [0] * (n + 1)
	dfs(1, 0)
	if f:
		print('NO')
	else:
		print('YES')


from sys import stdin, stdout
from math import gcd, sqrt, factorial, pi, inf
from collections import deque, defaultdict
from bisect import bisect, bisect_left
from time import time
from itertools import permutations as per
input = stdin.readline
R = lambda : map(int, input().split())
I = lambda : int(input())
S = lambda : input().rstrip('\r\n')
L = lambda : list(R())
P = lambda x: stdout.write(str(x) + '\n')
lcm = lambda x, y: x * y // gcd(x, y)
nCr = lambda x, y: f[x] * inv(f[y] * f[x - y] % N) % N
inv = lambda x: pow(x, N - 2, N)
sm = lambda x: (x ** 2 + x) // 2
N = 10 ** 9 + 7

def hap(x, y):
	if x % 2 != abs(y) % 2 or abs(y) > x:
		return 'NO'
	return (x + y) // 2
for _ in range(I()):
	(n, m) = R()
	p = [0] + L()
	h = [0] + L()
	a = [[] for i in range(n + 1)]
	dg = [0] * (n + 1)
	for i in range(n - 1):
		(x, y) = R()
		a[x] += (y,)
		a[y] += (x,)
		dg[x] += 1
		dg[y] += 1
	v = [1]
	stk = [1]
	pr = [0] * (n + 1)
	vst = [1] * (n + 1)
	vst[1] = 0
	while stk:
		val = stk.pop()
		for el in a[val]:
			if vst[el]:
				stk += (el,)
				v += (el,)
				pr[el] = val
				vst[el] = 0
	hp = [0] * (n + 1)
	ans = 'YES'
	for i in v[::-1]:
		x = hap(p[i], h[i])
		if x == 'NO':
			ans = 'NO'
			break
		if (i == 1 or dg[i] != 1) and x < hp[i]:
			ans = 'NO'
			break
		hp[pr[i]] += x
		p[pr[i]] += p[i]
	print(ans)


import sys
sys.setrecursionlimit(5056)

def f(k, z):
	s = 0
	for t in g[k]:
		if t ^ z:
			f(t, k)
			p[k] += p[t]
			s += h[t]
	h[k] += p[k]
	p[0] &= ~h[k] & (s <= h[k] <= 2 * p[k])
B = lambda : map(int, input().split())
(t,) = B()
for _ in [0] * t:
	B()
	p = [1, *B()]
	h = [0, *B()]
	g = [[] for _ in p]
	for _ in p[2:]:
		(z, y) = B()
		g[z] += (y,)
		g[y] += (z,)
	f(1, 0)
	print('NYOE S'[p[0]::2])


import sys
sys.setrecursionlimit(100005)
input = sys.stdin.readline
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	population = list(map(int, input().split()))
	happiness = list(map(int, input().split()))
	AdjList = [[] for _ in range(n)]
	for _ in range(n - 1):
		(u, v) = map(lambda x: int(x) - 1, input().split())
		AdjList[u].append(v)
		AdjList[v].append(u)

	def dfs(node, parent):
		happy_traveller = 0
		for child in AdjList[node]:
			if child == parent:
				continue
			(minhappy, transit, flag) = dfs(child, node)
			if flag:
				return (minhappy, transit, flag)
			happy_traveller += minhappy
			population[node] += transit
		happy_total = (population[node] + happiness[node]) // 2
		return (happy_total, population[node], happy_total < happy_traveller or (population[node] - happiness[node]) % 2 == 1 or happy_total < 0 or (happy_total > population[node]))
	(_, _, flag) = dfs(0, -1)
	if flag == False:
		print('YES')
	else:
		print('NO')


from bisect import *
from collections import *
from math import gcd, ceil, sqrt, floor, inf
from heapq import *
from itertools import *
from operator import add, mul, sub, xor, truediv, floordiv
from functools import *
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 RL():
	return map(int, sys.stdin.readline().rstrip().split())

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

def N():
	return int(input())
from types import GeneratorType

def bootstrap(f, stack=[]):

	def wrappedfunc(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		else:
			to = f(*args, **kwargs)
			while True:
				if type(to) is GeneratorType:
					stack.append(to)
					to = next(to)
				else:
					stack.pop()
					if not stack:
						break
					to = stack[-1].send(to)
			return to
	return wrappedfunc
farr = [1]
ifa = []

def fact(x, mod=0):
	if mod:
		while x >= len(farr):
			farr.append(farr[-1] * len(farr) % mod)
	else:
		while x >= len(farr):
			farr.append(farr[-1] * len(farr))
	return farr[x]

def ifact(x, mod):
	global ifa
	ifa.append(pow(farr[-1], mod - 2, mod))
	for i in range(x, 0, -1):
		ifa.append(ifa[-1] * i % mod)
	ifa = ifa[::-1]

def per(i, j, mod=0):
	if i < j:
		return 0
	if not mod:
		return fact(i) // fact(i - j)
	return farr[i] * ifa[i - j] % mod

def com(i, j, mod=0):
	if i < j:
		return 0
	if not mod:
		return per(i, j) // fact(j)
	return per(i, j, mod) * ifa[j] % mod

def catalan(n):
	return com(2 * n, n) // (n + 1)

def linc(f, t, l, r):
	while l < r:
		mid = (l + r) // 2
		if t > f(mid):
			l = mid + 1
		else:
			r = mid
	return l

def rinc(f, t, l, r):
	while l < r:
		mid = (l + r + 1) // 2
		if t < f(mid):
			r = mid - 1
		else:
			l = mid
	return l

def ldec(f, t, l, r):
	while l < r:
		mid = (l + r) // 2
		if t < f(mid):
			l = mid + 1
		else:
			r = mid
	return l

def rdec(f, t, l, r):
	while l < r:
		mid = (l + r + 1) // 2
		if t > f(mid):
			r = mid - 1
		else:
			l = mid
	return l

def isprime(n):
	for i in range(2, int(n ** 0.5) + 1):
		if n % i == 0:
			return False
	return True

def binfun(x):
	c = 0
	for w in arr:
		c += ceil(w / x)
	return c

def lowbit(n):
	return n & -n

def inverse(a, m):
	a %= m
	if a <= 1:
		return a
	return (1 - inverse(m, a) * m) // a % m

class BIT:

	def __init__(self, arr):
		self.arr = arr
		self.n = len(arr) - 1

	def update(self, x, v):
		while x <= self.n:
			self.arr[x] += v
			x += x & -x

	def query(self, x):
		ans = 0
		while x:
			ans += self.arr[x]
			x &= x - 1
		return ans

class DSU:

	def __init__(self, n):
		self.c = [-1] * n

	def same(self, x, y):
		return self.find(x) == self.find(y)

	def find(self, x):
		if self.c[x] < 0:
			return x
		self.c[x] = self.find(self.c[x])
		return self.c[x]

	def union(self, u, v):
		(u, v) = (self.find(u), self.find(v))
		if u == v:
			return False
		if self.c[u] < self.c[v]:
			(u, v) = (v, u)
		self.c[u] += self.c[v]
		self.c[v] = u
		return True

	def size(self, x):
		return -self.c[self.find(x)]

class UFS:

	def __init__(self, n):
		self.parent = [i for i in range(n)]
		self.ranks = [0] * n

	def find(self, x):
		if x != self.parent[x]:
			self.parent[x] = self.find(self.parent[x])
		return self.parent[x]

	def union(self, u, v):
		(pu, pv) = (self.find(u), self.find(v))
		if pu == pv:
			return False
		if self.ranks[pu] >= self.ranks[pv]:
			self.parent[pv] = pu
			if self.ranks[pv] == self.ranks[pu]:
				self.ranks[pu] += 1
		else:
			self.parent[pu] = pv

def Prime(n):
	c = 0
	prime = []
	flag = [0] * (n + 1)
	for i in range(2, n + 1):
		if not flag[i]:
			prime.append(i)
			c += 1
		for j in range(c):
			if i * prime[j] > n:
				break
			flag[i * prime[j]] = prime[j]
			if i % prime[j] == 0:
				break
	return prime

def dij(s, graph):
	d = {}
	d[s] = 0
	heap = [(0, s)]
	seen = set()
	while heap:
		(dis, u) = heappop(heap)
		if u in seen:
			continue
		for v in graph[u]:
			if v not in d or d[v] > d[u] + graph[u][v]:
				d[v] = d[u] + graph[u][v]
				heappush(heap, (d[v], v))
	return d

def GP(it):
	return [(ch, len(list(g))) for (ch, g) in groupby(it)]

class DLN:

	def __init__(self, val):
		self.val = val
		self.pre = None
		self.next = None

@bootstrap
def dfs(r, par):
	if len(g[r]) == 1 and par != -1:
		cnt[r] = p[r]
		yield None
	cnt[r] = p[r]
	for ch in g[r]:
		if ch != par:
			yield dfs(ch, r)
			cnt[r] += cnt[ch]
	yield None

@bootstrap
def dfs2(r, par):
	if cnt[r] + h[r] & 1 or cnt[r] < h[r] or cnt[r] + h[r] < 0:
		yield False
	if len(g[r]) != 1 or par == -1:
		res = -p[r]
		for ch in g[r]:
			if ch != par:
				res += h[ch]
		if res > h[r]:
			yield False
	for ch in g[r]:
		if ch != par:
			tmp = (yield dfs2(ch, r))
			if not tmp:
				yield False
	yield True
t = N()
for i in range(t):
	(n, m) = RL()
	p = RLL()
	h = RLL()
	cnt = [0] * n
	g = [[] for i in range(n)]
	for i in range(n - 1):
		(u, v) = RL()
		u -= 1
		v -= 1
		g[v].append(u)
		g[u].append(v)
	dfs(0, -1)
	ans = dfs2(0, -1)
	print('YES' if ans else 'NO')


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	p_num = [int(item) for item in input().split()]
	h = [int(item) for item in input().split()]
	edge = [[] for _ in range(n)]
	for _ in range(n - 1):
		(u, v) = map(int, input().split())
		u -= 1
		v -= 1
		edge[u].append(v)
		edge[v].append(u)
	sump = p_num[:]

	def dfs(p, v):
		st = []
		st.append((v, p, -1))
		st.append((p, v, 1))
		while st:
			(p, v, d) = st.pop()
			if d == 1:
				for nv in edge[v]:
					if nv == p:
						continue
					st.append((nv, v, -1))
				for nv in edge[v]:
					if nv == p:
						continue
					st.append((v, nv, 1))
			if d == -1 and v != -1:
				sump[v] += sump[p]
	dfs(-1, 0)
	h_num = [0] * n
	u_num = [0] * n
	ok = True

	def dfs2(p, v):
		global ok
		st = []
		st.append((p, v))
		while st:
			(p, v) = st.pop()
			people = sump[v]
			h_num[v] = (people + h[v]) // 2
			if (people + h[v]) % 2 == 1 or h_num[v] < 0:
				ok = False
			u_num[v] = people - h_num[v]
			if u_num[v] < 0:
				ok = False
			for nv in edge[v]:
				if nv == p:
					continue
				st.append((v, nv))
	dfs2(-1, 0)
	if ok == False:
		print('NO')
		continue

	def dfs3(p, v):
		global ok
		st = []
		st.append((p, v))
		while st:
			(p, v) = st.pop()
			hc = 0
			uc = 0
			for nv in edge[v]:
				if nv == p:
					continue
				hc += h_num[nv]
				uc += u_num[nv]
				st.append((v, nv))
			if hc + uc + p_num[v] != sump[v] or hc > h_num[v]:
				ok = False
	dfs3(-1, 0)
	if ok:
		print('YES')
	else:
		print('NO')


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, m) = list(map(int, input().split()))
	graph = [[] for i in range(n)]
	M = list(map(int, input().split()))
	H = list(map(int, input().split()))
	for i in range(n - 1):
		(a, b) = list(map(int, input().split()))
		graph[a - 1].append(b - 1)
		graph[b - 1].append(a - 1)
	bad = [0] * n
	total = [0] * n
	OK = 1
	pushed = [0] * n
	dad = [-1] * n
	bfs = [0]
	pushed[0] = 1
	while len(bfs) > 0:
		node = bfs[-1]
		flag = 0
		for i in graph[node]:
			if pushed[i] == 0:
				flag = 1
				bfs.append(i)
				pushed[i] = 1
				dad[i] = node
		if flag == 0:
			total[node] += M[node]
			if node != 0:
				total[dad[node]] += total[node]
			if (total[node] - H[node]) % 2 != 0:
				OK = 0
				break
			bad[node] = (total[node] - H[node]) // 2
			if bad[node] > total[node] or bad[node] < 0:
				OK = 0
				break
			bfs.pop(-1)
	if OK == 0:
		print('NO')
		continue
	pushed = [0] * n
	bfs = [0]
	pushed[0] = 1
	while len(bfs) > 0:
		node = bfs[-1]
		bfs.pop(-1)
		bad_in_children = 0
		for i in graph[node]:
			if pushed[i] == 0:
				bfs.append(i)
				pushed[i] = 1
				bad_in_children += bad[i]
		if bad_in_children < bad[node] - M[node]:
			OK = 0
	if OK == 0:
		print('NO')
	else:
		print('YES')


import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)
from collections import defaultdict
con = 10 ** 9 + 7
INF = float('inf')

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

class Graph(object):

	def __init__(self):
		self.graph = defaultdict(list)

	def __len__(self):
		return len(self.graph)

	def add_edge(self, a, b):
		self.graph[a].append(b)

def DFS(G, P, H, visit, left, val, node):
	left[node] -= P[node]
	val[node] += P[node]
	for i in G.graph[node]:
		if visit[i] != 1:
			visit[i] = 1
			DFS(G, P, H, visit, left, val, i)
			left[node] += left[i]
			val[node] += val[i]
	global jud
	if left[node] <= H[node] and H[node] <= left[node] + 2 * val[node] and ((H[node] - left[node]) % 2 == 0):
		val[node] -= (H[node] - left[node]) // 2
		left[node] = H[node]
	else:
		jud = 'NO'
T = int(input())
for _ in range(T):
	(N, M) = getlist()
	G = Graph()
	P = getlist()
	H = getlist()
	for i in range(N - 1):
		(x, y) = getlist()
		x -= 1
		y -= 1
		G.add_edge(x, y)
		G.add_edge(y, x)
	visit = [0] * N
	visit[0] = 1
	left = [0] * N
	val = [0] * N
	jud = 'YES'
	DFS(G, P, H, visit, left, val, 0)
	print(jud)


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')
import sys, threading
sys.setrecursionlimit(400000)
threading.stack_size(10 ** 8)

def dfs(x):
	global v, l1, l2, adj, ans, s
	v[x] = 1
	s[x] = l1[x - 1]
	h = 0
	l = []
	for i in adj[x]:
		if not v[i]:
			l.append(i)
			dfs(i)
			s[x] += s[i]
			if s[i]:
				h += l2[i - 1]
	if (s[x] + l2[x - 1]) % 2:
		ans = 'NO'
		return
	a = (s[x] + l2[x - 1]) // 2
	b = (s[x] - l2[x - 1]) // 2
	if b < 0 or a < 0 or a > s[x] or (b > s[x]):
		ans = 'NO'
		return
	if (s[x] - l1[x - 1] + h) % 2:
		ans = 'NO'
		return
	c = (s[x] - l1[x - 1] + h) // 2
	d = (s[x] - l1[x - 1] - h) // 2
	if c > a or d > b + a - c or c < 0 or (d < 0):
		ans = 'NO'
		return
	a = (s[x] - l1[x - 1] + h) // 2
	b = (s[x] - l1[x - 1] - h) // 2
	p = 0
	for i in l:
		c = (s[i] + l2[i - 1]) // 2
		d = (s[i] - l2[i - 1]) // 2
		p += c
		if c > a or d > b or c < 0 or (d < 0):
			ans = 'NO'
			return
		if c > s[i] or d > s[i]:
			ans = 'NO'
			return
	if p > a or p < 0:
		ans = 'NO'
		return

def main():
	global v, l1, l2, adj, ans, s
	t = int(input())
	for i in range(t):
		(n, m) = map(int, input().split())
		l1 = list(map(int, input().split()))
		l2 = list(map(int, input().split()))
		v = [0] * (n + 1)
		s = [0] * (n + 1)
		ans = 'YES'
		adj = [[] for j in range(n + 1)]
		for j in range(n - 1):
			(x, y) = map(int, input().split())
			adj[x].append(y)
			adj[y].append(x)
		dfs(1)
		print(ans)
z = threading.Thread(target=main)
z.start()
z.join()


from collections import defaultdict
import sys, math
f = None
try:
	f = open('q1.input', 'r')
except IOError:
	f = sys.stdin
if 'xrange' in dir(__builtins__):
	range = xrange

def print_case_iterable(case_num, iterable):
	print('Case #{}: {}'.format(case_num, ' '.join(map(str, iterable))))

def print_case_number(case_num, iterable):
	print('Case #{}: {}'.format(case_num, iterable))

def print_iterable(A):
	print(' '.join(A))

def read_int():
	return int(f.readline().strip())

def read_int_array():
	return [int(x) for x in f.readline().strip().split(' ')]

def rns():
	a = [x for x in f.readline().split(' ')]
	return (int(a[0]), a[1].strip())

def read_string():
	return list(f.readline().strip())

def ri():
	return int(f.readline().strip())

def ria():
	return [int(x) for x in f.readline().strip().split(' ')]

def rns():
	a = [x for x in f.readline().split(' ')]
	return (int(a[0]), a[1].strip())

def rs():
	return list(f.readline().strip())

def bi(x):
	return bin(x)[2:]
from collections import deque
import math
NUMBER = 10 ** 9 + 7

def factorial(n):
	M = NUMBER
	f = 1
	for i in range(1, n + 1):
		f = f * i % M
	return f

def mult(a, b):
	return a * b % NUMBER

def minus(a, b):
	return (a - b) % NUMBER

def plus(a, b):
	return (a + b) % NUMBER

def egcd(a, b):
	if a == 0:
		return (b, 0, 1)
	else:
		(g, y, x) = egcd(b % a, a)
		return (g, x - b // a * y, y)

def modinv(a):
	m = NUMBER
	(g, x, y) = egcd(a, m)
	if g != 1:
		raise Exception('modular inverse does not exist')
	else:
		return x % m

def choose(n, k):
	if n < k:
		assert false
	return mult(factorial(n), modinv(mult(factorial(k), factorial(n - k)))) % NUMBER
from collections import deque, defaultdict
import heapq
from types import GeneratorType

def bootstrap(f, stack=[]):

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

def dfs(g, timeIn, timeOut, depths, parents):
	cnt = 0
	stack = [[1, 0, 0, 0]]
	while stack:
		(v, neig_i, parent, depth) = stack[-1]
		parents[v] = parent
		depths[v] = depth
		if neig_i == 0:
			timeIn[v] = cnt
			cnt += 1
		while neig_i < len(g[v]):
			u = g[v][neig_i]
			if u == parent:
				neig_i += 1
				continue
			stack[-1][1] = neig_i + 1
			stack.append([u, 0, v, depth + 1])
			break
		if neig_i == len(g[v]):
			stack.pop()
			timeOut[v] = cnt
			cnt += 1
cnt = 0

@bootstrap
def dfs(v, adj, timeIn, timeOut, depths, parents, parent=0, depth=0):
	global cnt
	parents[v] = parent
	depths[v] = depth
	timeIn[v] = cnt
	cnt += 1
	for u in adj[v]:
		if u == parent:
			continue
		yield dfs(u, adj, timeIn, timeOut, depths, parents, v, depth + 1)
	timeOut[v] = cnt
	cnt += 1
	yield

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

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

def get_num_2_5(n):
	twos = 0
	fives = 0
	while n > 0 and n % 2 == 0:
		n //= 2
		twos += 1
	while n > 0 and n % 5 == 0:
		n //= 5
		fives += 1
	return (twos, fives)

def shift(a, i, num):
	for _ in range(num):
		(a[i], a[i + 1], a[i + 2]) = (a[i + 2], a[i], a[i + 1])

def equal(x, y):
	return abs(x - y) <= 1e-09

def getAngle(a, b, c):
	ang = math.degrees(math.atan2(c[1] - b[1], c[0] - b[0]) - math.atan2(a[1] - b[1], a[0] - b[0]))
	return ang + 360 if ang < 0 else ang

def getLength(a, b):
	return math.sqrt((a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2)
from heapq import heapify, heappush, heappop

def bfs(adj):
	s = set()
	d = defaultdict(set)
	q = deque([])
	s.add(0)
	d[0].add(0)
	q.append((0, 0))
	while len(q) > 0:
		(v, depth) = q.popleft()
		for u in adj[v]:
			if u not in s:
				s.add(u)
				d[depth + 1].add(u)
				q.append((u, depth + 1))
	return d

def isSubsetSum(arr, n, summ):
	subarr = [[False for i in range(summ + 1)] for i in range(n + 1)]
	for i in range(n + 1):
		subarr[i][0] = True
	for i in range(1, summ + 1):
		subarr[0][i] = False
	for i in range(1, n + 1):
		for j in range(1, summ + 1):
			if j < arr[i - 1]:
				subarr[i][j] = subarr[i - 1][j]
			if j >= arr[i - 1]:
				subarr[i][j] = subarr[i - 1][j] or subarr[i - 1][j - arr[i - 1]]
	return subarr[n][summ]

def bfs(v, adj, onpath):
	s = set()
	d = defaultdict(set)
	q = deque([])
	s.add(0)
	d[0].add(0)
	q.append((0, 0))
	while len(q) > 0:
		(v, depth) = q.popleft()
		for u in adj[v]:
			if u not in s:
				s.add(u)
				d[depth + 1].add(u)
				q.append((u, depth + 1))
	return d

@bootstrap
def dfs(v, pa, adj, p, h):
	s = 0
	num = p[v]
	for u in adj[v]:
		if pa == u:
			continue
		(x, y) = (yield dfs(u, v, adj, p, h))
		if x == -1:
			yield (-1, -1)
		num += x
		s += y
	if h[v] % 2 != num % 2 or h[v] < s - p[v] or h[v] > num or (h[v] < -num):
		yield (-1, -1)
	yield (num, h[v])

def solution(adj, n, p, m, h):
	(x, y) = dfs(0, -1, adj, p, h)
	if x == -1:
		return 'No'
	return 'Yes'

def main():
	T = 1
	T = ri()
	for i in range(T):
		(n, m) = ria()
		p = ria()
		h = ria()
		adj = [list() for _ in range(n)]
		for j in range(n - 1):
			(a, b) = ria()
			a -= 1
			b -= 1
			adj[a].append(b)
			adj[b].append(a)
		x = solution(adj, n, p, m, h)
		if 'xrange' not in dir(__builtins__):
			print(x)
		else:
			(print >> output, str(x))
	if 'xrange' in dir(__builtins__):
		print(output.getvalue())
		output.close()
if 'xrange' in dir(__builtins__):
	import cStringIO
	output = cStringIO.StringIO()
main()


from __future__ import division, print_function
import sys
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip
import os, sys, bisect, copy
from collections import defaultdict, Counter, deque
if os.path.exists('in.txt'):
	sys.stdin = open('in.txt', 'r')
if os.path.exists('out.txt'):
	sys.stdout = open('out.txt', 'w')

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

def mapi(arg=0):
	return map(int if arg == 0 else str, input().split())
import sys
sys.setrecursionlimit(10 ** 8)
from types import GeneratorType

def bootstrap(func, stack=[]):

	def wrapped_function(*args, **kwargs):
		if stack:
			return func(*args, **kwargs)
		else:
			call = func(*args, **kwargs)
			while True:
				if type(call) is GeneratorType:
					stack.append(call)
					call = next(call)
				else:
					stack.pop()
					if not stack:
						break
					call = stack[-1].send(call)
			return call
	return wrapped_function
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	p = list(map(int, input().split()))
	h = list(map(int, input().split()))
	gr = defaultdict(list)
	for i in range(n - 1):
		(x, y) = map(int, input().split())
		gr[x].append(y)
		gr[y].append(x)

	@bootstrap
	def dfs(s, par):
		sz[s] = p[s - 1]
		gg = 0
		bb = 0
		for i in gr[s]:
			if i == par:
				continue
			if not (yield dfs(i, s)):
				yield False
			sz[s] += sz[i]
			gg += g[i]
			bb += b[i]
		g[s] = (sz[s] + h[s - 1]) // 2
		b[s] = (sz[s] - h[s - 1]) // 2
		if gg < 0 or bb < 0 or 2 * g[s] != sz[s] + h[s - 1] or (gg > g[s]) or (g[s] > sz[s]) or (g[s] < 0):
			yield False
		yield True
	g = [0] * (n + 1)
	b = [0] * (n + 1)
	sz = [0] * (n + 1)
	if dfs(1, -1):
		print('YES')
	else:
		print('NO')


from collections import Counter
import math
array = [6, 10, 14, 15]

def fun(graph, population, n):
	ans = population[:]
	stack = [1]
	visited = [0] * n
	parent = [0] * (n + 1)
	parent[1] = -1
	while len(stack) > 0:
		cur = stack[-1]
		if visited[cur - 1] == 0:
			visited[cur - 1] = 1
			for i in graph[cur]:
				if visited[i - 1] == 0:
					parent[i] = cur
					stack.append(i)
		else:
			stack.pop()
			for i in graph[cur]:
				if i != parent[cur]:
					ans[cur - 1] += ans[i - 1]
	return (ans, parent)

def check(graph, parent, suffixPop, population, n, happiness):
	visited = [0] * n
	stack = [1]
	badmood = [0] * (n + 1)
	badmood[1] = (suffixPop[0] - happiness[0]) / 2
	if int(badmood[1]) != badmood[1] or badmood[1] < 0 or badmood[1] > suffixPop[0]:
		return 'NO'
	while len(stack) > 0:
		cur = stack.pop()
		visited[cur - 1] = 1
		childBadmood = 0
		haschild = False
		for i in graph[cur]:
			if visited[i - 1] == 0:
				haschild = True
				visited[i - 1] = 1
				badmood[i] = (suffixPop[i - 1] - happiness[i - 1]) / 2
				if int(badmood[i]) != badmood[i] or badmood[i] < 0 or badmood[i] > suffixPop[i - 1]:
					return 'NO'
				childBadmood += badmood[i]
				stack.append(i)
		badmood[cur] = max(0, badmood[cur] - population[cur - 1])
		if haschild and childBadmood < badmood[cur]:
			return 'NO'
	return 'YES'
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	population = list(map(int, input().split()))
	happiness = list(map(int, input().split()))
	if n == 1:
		badmood = [0, 0]
		badmood[1] = (population[0] - happiness[0]) / 2
		if int(badmood[1]) != badmood[1] or badmood[1] < 0 or badmood[1] > population[0]:
			print('NO')
		else:
			print('YES')
	else:
		graph = {}
		for i in range(n - 1):
			(x, y) = map(int, input().split())
			if x not in graph:
				graph[x] = []
			if y not in graph:
				graph[y] = []
			graph[x].append(y)
			graph[y].append(x)
		(suffixPop, parent) = fun(graph, population, n)
		print(check(graph, parent, suffixPop, population, n, happiness))


import heapq
import collections
from math import log2
import itertools
from functools import lru_cache
from sys import setrecursionlimit as srl
import math
srl(5 * 10 ** 6)

def dfs(z, par, p, h, graph, tot, b, g):
	global poss
	badchild = 0
	tot[z] = p[z]
	for x in graph[z]:
		if x == par:
			continue
		dfs(x, z, p, h, graph, tot, b, g)
		tot[z] += tot[x]
		badchild += b[x]
	if h[z] > tot[z]:
		poss = 0
	if h[z] < -tot[z]:
		poss = 0
	if (tot[z] + h[z]) % 2:
		poss = 0
	g[z] = (tot[z] + h[z]) // 2
	b[z] = (tot[z] - h[z]) // 2
	if b[z] > p[z] + badchild:
		poss = 0

def solve(n, m, p, h, graph):
	tot = [0] * (n + 1)
	b = [0] * (n + 1)
	g = [0] * (n + 1)
	global poss
	poss = 1
	dfs(1, 0, p, h, graph, tot, b, g)
	if poss:
		return 'YES'
	else:
		return 'NO'
t = int(input())
while t:
	(n, m) = map(int, input().split())
	p = [0] + list(map(int, input().split()))
	h = [0] + list(map(int, input().split()))
	graph = collections.defaultdict(list)
	for _ in range(1, n):
		(u, v) = map(int, input().split())
		graph[u].append(v)
		graph[v].append(u)
	print(solve(n, m, p, h, graph))
	t -= 1


import sys
input = sys.stdin.buffer.readline
from types import GeneratorType

def bootstrap(f, stack=[]):

	def wrappedfunc(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		else:
			to = f(*args, **kwargs)
			while True:
				if type(to) is GeneratorType:
					stack.append(to)
					to = next(to)
				else:
					stack.pop()
					if not stack:
						break
					to = stack[-1].send(to)
			return to
	return wrappedfunc
t = int(input())
for zzz in range(t):
	(n, m) = [int(x) for x in input().split()]
	p = [int(x) for x in input().split()]
	h = [int(x) for x in input().split()]
	p.insert(0, 0)
	h.insert(0, 0)
	edges = [[] for _ in range(n + 1)]
	for zz in range(n - 1):
		(u, v) = [int(x) for x in input().split()]
		edges[u].append(v)
		edges[v].append(u)
	ok = [True]

	@bootstrap
	def dfs(node, parent):
		T = p[node]
		minH = 0
		for nextt in edges[node]:
			if nextt != parent:
				(a, b) = (yield dfs(nextt, node))
				T += a
				minH += b
		temp = h[node] + T
		if temp % 2 == 1:
			ok[0] = False
		actualH = temp // 2
		actualS = T - actualH
		if actualH < 0 or actualS < 0:
			ok[0] = False
		if actualH < minH:
			ok[0] = False
		yield (T, actualH)
	dfs(1, 0)
	if ok[0]:
		print('YES')
	else:
		print('NO')


from sys import setrecursionlimit
setrecursionlimit(10 ** 8)

def dfs(p, prev):
	for i in child[p]:
		if i != prev:
			dfs(i, p)
			a[p - 1] += a[i - 1]

def dfs1(p, prev):
	global ans
	v = h[p - 1] + a[p - 1]
	if v & 1:
		ans = 'NO'
	g = v // 2
	if g > a[p - 1] or g < 0:
		ans = 'NO'
	s = 0
	for i in child[p]:
		if i != prev:
			s += dfs1(i, p)
	if g < s:
		ans = 'NO'
	return g
for T in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	h = list(map(int, input().split()))
	child = [[] for i in range(n + 1)]
	for i in range(n - 1):
		(u, v) = map(int, input().split())
		child[u].append(v)
		child[v].append(u)
	dfs(1, -1)
	ans = 'YES'
	dfs1(1, -1)
	print(ans)


import sys
readline = sys.stdin.buffer.readline
ns = lambda : readline().rstrip()
ni = lambda : int(readline().rstrip())
nm = lambda : map(int, readline().split())
nl = lambda : list(map(int, readline().split()))

def solve():
	(n, m) = nm()
	p = nl()
	h = nl()
	G = [list() for _ in range(n)]
	for _ in range(n - 1):
		(u, v) = nm()
		u -= 1
		v -= 1
		G[u].append(v)
		G[v].append(u)
	ls = [-1] * n
	rs = [-1] * n
	par = [-1] * n
	dfsl = []
	ch = [0] * n

	def dfs_v(root=0):
		t = 0
		stack = [root]
		while stack:
			v = stack[-1]
			if ls[v] < 0:
				dfsl.append(v)
				ls[v] = t
				t += 1
				for u in G[v]:
					if u == par[v]:
						continue
					par[u] = v
					stack.append(u)
			else:
				rs[v] = t
				stack.pop()
		return
	dfs_v()
	for v in reversed(dfsl):
		c = p[v] + h[v]
		if c & 1:
			print('NO')
			return
		c >>= 1
		if c < 0 or p[v] < c or ch[v] > c:
			print('NO')
			return
		ch[par[v]] += c
		p[par[v]] += p[v]
	print('YES')
	return
T = ni()
for _ in range(T):
	solve()


import os
from collections import defaultdict, deque
is_dev = 'vscode' in os.environ
if is_dev:
	inF = open('in.txt', 'r')
	outF = open('out.txt', 'w')

def ins(r):
	return list(map(int, r.split(' ')))

def input_():
	if is_dev:
		return inF.readline()[:-1]
	else:
		return input()

def print_(data):
	if is_dev:
		outF.write(str(data) + '\n')
	else:
		print(data)

def possible(x):
	if not (-n_people_use_node[x] <= measurement[x] <= n_people_use_node[x] and n_people_use_node[x] % 2 == measurement[x] % 2):
		raise Exception('Not possible')
	if childs[x] == set():
		min_measurement_node[x] = measurement[x]
	else:
		min_measurement_node[x] = -n_people_leaving[x]
		for child in childs[x]:
			min_measurement_node[x] += min_measurement_node[child]
		if min_measurement_node[x] > measurement[x]:
			raise Exception('Not possible')
		min_measurement_node[x] = max(min_measurement_node[x], measurement[x])
try:
	for _ in range(int(input_())):
		(n, m) = ins(input_())
		n_people_leaving = ins(input_())
		n_people_leaving.insert(0, 0)
		measurement = ins(input_())
		measurement.insert(0, 0)
		graph = defaultdict(list)
		for _ in range(n - 1):
			(a, b) = ins(input_())
			graph[a].append(b)
			graph[b].append(a)
		parent = [0] * (n + 1)
		parent[1] = 1
		childs = defaultdict(list)
		levels = [0] * (n + 1)
		level_nodes = defaultdict(list)
		levels[1] = -1
		largest_level = 0
		queue = deque([1])
		while len(queue) >= 1:
			x = queue.popleft()
			levels[x] = levels[parent[x]] + 1
			level_nodes[levels[x]].append(x)
			largest_level = max(largest_level, levels[x])
			for i in graph[x]:
				if parent[i] == 0:
					parent[i] = x
					queue.append(i)
					childs[x].append(i)
		n_people_use_node = [0] * (n + 1)
		min_measurement_node = [0] * (n + 1)
		try:
			for i in range(largest_level, -1, -1):
				for j in level_nodes[i]:
					total = n_people_leaving[j]
					for child in childs[j]:
						total += n_people_use_node[child]
					n_people_use_node[j] = total
					min_measurement_node[j] = -total
					possible(j)
			print_('YES')
		except Exception as e:
			if str(e) == 'Not possible':
				print_('NO')
			else:
				raise
except e:
	print(e)
if is_dev:
	outF.close()

	def compare_file():
		print(open('out.txt', 'r').read() == open('outactual.txt', 'r').read())
	compare_file()