Given is a simple undirected graph with N vertices and M edges. The i-th edge connects Vertex c_i and Vertex d_i.
Initially, Vertex i has the value a_i written on it. You want to change the values on Vertex 1, \ldots, Vertex N to b_1, \cdots, b_N, respectively, by doing the operation below zero or more times.
 - Choose an edge, and let Vertex x and Vertex y be the vertices connected by that edge. Choose one of the following and do it:
 - Decrease the value a_x by 1, and increase the value a_y by 1.
 - Increase the value a_x by 1, and decrease the value a_y by 1.
Determine whether it is possible to achieve the objective by properly doing the operation.

-----Constraints-----
 - 1 \leq N \leq 2 \times 10^5
 - 0 \leq M \leq 2 \times 10^5
 - -10^9 \leq a_i,b_i \leq 10^9
 - 1 \leq c_i,d_i \leq N
 - The given graph is simple, that is, has no self-loops and no multi-edges.
 - All values in input are integers.

-----Input-----
Input is given from Standard Input in the following format:
N M
a_1 \cdots a_N
b_1 \cdots b_N
c_1 d_1
\vdots
c_M d_M

-----Output-----
Print Yes if it is possible to achieve the objective by properly doing the operation, and No otherwise.

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

-----Sample Output-----
Yes

You can achieve the objective by, for example, doing the operation as follows:
 - In the first operation, choose the edge connecting Vertex 1 and 2. Then, increase a_1 by 1 and decrease a_2 by 1.
 - In the second operation, choose the edge connecting Vertex 2 and 3. Then, increase a_2 by 1 and decrease a_3 by 1.
This sequence of operations makes a_1=2, a_2=2, and a_3=2.

Difficulty: MEDIUM_HARD

Solutions:
(N, M) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
cd = [list(map(int, input().split())) for i in range(M)]
li = [[] for i in range(N + 1)]
for i in range(M):
	li[cd[i][0]].append(cd[i][1])
	li[cd[i][1]].append(cd[i][0])
li2 = [0] * (N + 1)
num = 0
for i in range(1, N + 1):
	deque = [i]
	if li2[i] != 0:
		break
	li2[i] = i
	num = i
	while deque:
		x = deque.pop(0)
		for j in li[x]:
			if li2[j] == 0:
				li2[j] = i
				deque.append(j)
li3 = [[] for i in range(num)]
for i in range(1, N + 1):
	li3[li2[i] - 1].append(i - 1)
for i in range(len(li3)):
	A = 0
	B = 0
	for j in range(len(li3[i])):
		A += a[li3[i][j]]
		B += b[li3[i][j]]
	if A != B:
		print('No')
		break
	elif i == len(li3) - 1:
		print('Yes')


class UnionFind:

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

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

	def union(self, x, y):
		x = self.find(x)
		y = self.find(y)
		if x == y:
			return
		if self.parents[x] > self.parents[y]:
			(x, y) = (y, x)
		self.parents[x] += self.parents[y]
		self.parents[y] = x

	def members(self, x):
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i) == root]

	def roots(self):
		return [i for (i, x) in enumerate(self.parents) if x < 0]

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()}
(N, M) = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
UF = UnionFind(N)
for _ in range(M):
	(c, d) = map(int, input().split())
	UF.union(c - 1, d - 1)
a_sum = [0] * N
b_sum = [0] * N
for (i, (a, b)) in enumerate(zip(A, B)):
	a_sum[UF.find(i)] += a
	b_sum[UF.find(i)] += b
for (ai, bi) in zip(a_sum, b_sum):
	if ai != bi:
		print('No')
		break
else:
	print('Yes')


(N, M) = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))

class UnionFind:

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

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

	def union(self, x, y):
		x = self.find(x)
		y = self.find(y)
		if x == y:
			return
		if self.parents[x] > self.parents[y]:
			(x, y) = (y, x)
		self.parents[x] += self.parents[y]
		self.parents[y] = x

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

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

	def members(self, x):
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i) == root]

	def roots(self):
		return [i for (i, x) in enumerate(self.parents) if x < 0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()}

	def __str__(self):
		return '\n'.join(('{}: {}'.format(r, self.members(r)) for r in self.roots()))
tree = UnionFind(N)
for i in range(M):
	cd = list(map(int, input().split()))
	cd[0] -= 1
	cd[1] -= 1
	tree.union(cd[0], cd[1])
dict = {}
for i in range(N):
	x = tree.find(i)
	dict.setdefault(x, [])
	dict[x].append(i)
ans = 'Yes'
for i in dict:
	asum = 0
	bsum = 0
	for j in dict[i]:
		asum += a[j]
		bsum += b[j]
	if asum != bsum:
		ans = 'No'
print(ans)


from collections import defaultdict

class UnionFind:

	def __init__(self, num):
		self.roots = [i for i in range(num + 1)]
		self.ranks = [1 for _ in range(num + 1)]

	def get_root(self, node):
		if node != self.roots[node]:
			self.roots[node] = self.get_root(self.roots[node])
		return self.roots[node]

	def unite(self, node_1, node_2):
		root_1 = self.get_root(node_1)
		root_2 = self.get_root(node_2)
		if root_1 == root_2:
			return
		elif self.ranks[root_1] > self.ranks[root_2]:
			self.roots[root_2] = root_1
		else:
			if self.ranks[root_1] == self.ranks[root_2]:
				self.ranks[root_2] += 1
			self.roots[root_1] = root_2

	def get_root_list(self):
		for i in range(len(self.roots)):
			self.get_root(i)
		return self.roots
(n, m) = map(int, input().split())
bef = list(map(int, input().split()))
aft = list(map(int, input().split()))
dif = [0] * n
for k in range(n):
	dif[k] = aft[k] - bef[k]
u = UnionFind(n)
for _ in range(m):
	(x, y) = map(int, input().split())
	u.unite(x, y)
u_list = u.get_root_list()
u_dict = defaultdict(set)
for z in range(n + 1):
	r = u_list[z]
	u_dict[r].add(z)
u_dict.pop(0)
flag = True
for d in u_dict.values():
	cnt = 0
	for dd in d:
		cnt += dif[dd - 1]
	if cnt != 0:
		flag = False
		break
if flag:
	print('Yes')
else:
	print('No')


class UnionFind:

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

	def unite(self, x, y):
		rx = self.root(x)
		ry = self.root(y)
		if rx == ry:
			return
		if self.par[rx] > self.par[ry]:
			(rx, ry) = (ry, rx)
		self.par[rx] += self.par[ry]
		self.par[ry] = rx

	def root(self, x):
		if self.par[x] < 0:
			return x
		else:
			self.par[x] = self.root(self.par[x])
			return self.par[x]

	def same(self, x, y):
		if self.root(x) == self.root(y):
			return True
		else:
			return False

	def rank(self, x):
		return -1 * self.par[self.root(x)]

	def root_num(self):
		retval = 0
		for i in range(self.n):
			if self.par[i] < 0:
				retval += 1
		return retval

	def set_list(self):
		l = [[-1] for i in range(self.n)]
		for i in range(self.n):
			if self.par[i] < 0:
				l[i].append(i)
			else:
				l[self.root(i)].append(i)
		for i in range(self.n - 1, -1, -1):
			del l[i][0]
			if len(l[i]) == 0:
				del l[i]
		return l
(N, M) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
uf = UnionFind(N)
for _ in range(M):
	l = list(map(int, input().split()))
	uf.unite(l[0] - 1, l[1] - 1)
l = uf.set_list()
for i in range(len(l)):
	sumA = 0
	sumB = 0
	for j in range(len(l[i])):
		sumA += a[l[i][j]]
		sumB += b[l[i][j]]
	if sumA != sumB:
		print('No')
		return
print('Yes')


import sys
input = sys.stdin.readline
(n, m) = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))

class UnionFind:

	def __init__(self, n):
		self.par = [-1] * (n + 1)
		self.sizes = [1] * (n + 1)

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

	def union(self, x, y):
		x = self.find(x)
		y = self.find(y)
		if x == y:
			return
		d1 = self.par[x]
		d2 = self.par[y]
		if d1 <= d2:
			self.par[y] = x
			self.sizes[x] = self.sizes[x] + self.sizes[y]
			if d1 == d2:
				self.par[x] = self.par[x] - 1
		else:
			self.par[x] = y
			self.sizes[y] = self.sizes[x] + self.sizes[y]

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

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

	def number(self):
		count = 0
		for i in self.par[1:]:
			if i < 0:
				count = count + 1
		return count
U = UnionFind(n)
for i in range(m):
	(c, d) = list(map(int, input().split()))
	c -= 1
	d -= 1
	U.union(c, d)
check = {}
for i in range(n):
	x = U.find(i)
	if x in check:
		check[x].append(i)
	else:
		check[x] = [i]
for i in check:
	l = check[i]
	A = 0
	B = 0
	for j in l:
		A += a[j]
		B += b[j]
	if A != B:
		print('No')
		return
print('Yes')


class UnionFind:

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

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

	def union(self, x, y):
		x = self.find(x)
		y = self.find(y)
		if x == y:
			return
		if self.parents[x] > self.parents[y]:
			(x, y) = (y, x)
		self.parents[x] += self.parents[y]
		self.parents[y] = x

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

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

	def __str__(self):
		return '\n'.join(('{}: {}'.format(r, self.members(r)) for r in self.roots()))
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
uf = UnionFind(n)
for i in range(m):
	(c, d) = map(int, input().split())
	uf.union(c - 1, d - 1)
sumA = {}
sumB = {}
for i in range(n):
	g = uf.find(i)
	if g in sumA:
		sumA[g] += a[i]
		sumB[g] += b[i]
	else:
		sumA[g] = a[i]
		sumB[g] = b[i]
ans = 'Yes'
for k in sumA.keys():
	if sumA[k] != sumB[k]:
		ans = 'No'
		break
print(ans)


class UnionFind:

	def __init__(self, n, A, B):
		self.n = n
		self.parents = [-1] * n
		self.values = [a - b for (a, b) in zip(A, B)]

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

	def union(self, x, y):
		x = self.find(x)
		y = self.find(y)
		if x == y:
			return
		if self.parents[x] > self.parents[y]:
			(x, y) = (y, x)
		self.parents[x] += self.parents[y]
		self.values[x] += self.values[y]
		self.parents[y] = x

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

	def roots(self):
		return [i for (i, x) in enumerate(self.parents) if x < 0]

	def members(self, x):
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i) == root]

	def num_members(self, x):
		return abs(self.parents[self.find(x)])

	def groups(self):
		roots = self.roots()
		r_to_g = {}
		for (i, r) in enumerate(roots):
			r_to_g[r] = i
		groups = [[] for _ in roots]
		for i in range(self.n):
			groups[r_to_g[self.find(i)]].append(i)
		return groups
import sys, os, io
input = sys.stdin.readline
(N, M) = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
uf = UnionFind(N, A, B)
for i in range(M):
	(c, d) = list(map(int, input().split()))
	uf.union(c - 1, d - 1)
for i in range(N):
	if uf.parents[i] < 0 and uf.values[i] != 0:
		print('No')
		return
print('Yes')


class UnionFind:

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

	def find_root(self, x):
		if self.parents[x] < 0:
			return x
		self.parents[x] = self.find_root(self.parents[x])
		return self.parents[x]

	def unite(self, x, y):
		root_x = self.find_root(x)
		root_y = self.find_root(y)
		if root_x == root_y:
			return
		if self.parents[root_x] > self.parents[root_y]:
			(root_x, root_y) = (root_y, root_x)
		self.parents[root_x] += self.parents[root_y]
		self.parents[root_y] = root_x

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

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

	def get_roots(self):
		roots = set()
		for (i, x) in enumerate(self.parents):
			if x < 0:
				roots.add(i)
		return roots

	def count_roots(self):
		return len(self.get_roots())
(N, M) = list(map(int, input().split()))
a = tuple(map(int, input().split()))
b = tuple(map(int, input().split()))
graph = UnionFind(N)
for i in range(M):
	(c, d) = list(map(int, input().split()))
	graph.unite(c - 1, d - 1)
(sum_a, sum_b) = ([0] * N, [0] * N)
for i in range(N):
	r = graph.find_root(i)
	sum_a[r] += a[i]
	sum_b[r] += b[i]
judge = 'Yes'
for r in graph.get_roots():
	if sum_a[r] != sum_b[r]:
		judge = 'No'
		break
print(judge)


import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(10 ** 7)
INF = float('inf')
MOD = 10 ** 9 + 7

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

def F():
	return float(input())

def SS():
	return input()

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

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

def LF():
	return [float(x) for x in input().split()]

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

class UnionFind:

	def __init__(self, n):
		self.n = n
		self.par = list(range(n))
		self.rank = [0] * n

	def root(self, x):
		if self.par[x] == x:
			return x
		else:
			r = self.root(self.par[x])
			self.par[x] = r
			return r

	def issame(self, x, y):
		return self.root(x) == self.root(y)

	def merge(self, x, y):
		x = self.root(x)
		y = self.root(y)
		if x == y:
			return False
		if self.rank[x] < self.rank[y]:
			(x, y) = (y, x)
		if self.rank[x] == self.rank[y]:
			self.rank[x] += 1
		self.par[y] = x
		return True

def resolve():
	(N, M) = LI()
	a = LI()
	b = LI()
	uf = UnionFind(N)
	for _ in range(M):
		(c, d) = LI_()
		uf.merge(c, d)
	d = collections.defaultdict(list)
	for i in range(N):
		p = uf.root(i)
		d[p].append(i)
	if [sum([a[j] for j in v]) == sum([b[j] for j in v]) for (k, v) in list(d.items())].count(False) == 0:
		print('Yes')
	else:
		print('No')

def __starting_point():
	resolve()
__starting_point()


from collections import defaultdict

class UnionFind:

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

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

	def union(self, x, y):
		x = self.find(x)
		y = self.find(y)
		if x == y:
			return
		if self.parents[x] > self.parents[y]:
			(x, y) = (y, x)
		self.parents[x] += self.parents[y]
		self.parents[y] = x

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

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

	def members(self, x):
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i) == root]

	def roots(self):
		return [i for (i, x) in enumerate(self.parents) if x < 0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		group_members = defaultdict(list)
		for member in range(self.n):
			group_members[self.find(member)].append(member)
		return group_members

	def __str__(self):
		return '\n'.join((f'{r}: {m}' for (r, m) in self.all_group_members().items()))
uf = UnionFind(6)
(n, m) = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
dic = {}
flag = True
for i in range(n):
	dic.setdefault(i, B[i] - A[i])
uf = UnionFind(n)
for _ in range(m):
	(c, d) = map(int, input().split())
	(c, d) = (c - 1, d - 1)
	uf.union(c, d)
for gr in uf.all_group_members().values():
	tem = 0
	for point in gr:
		tem += dic[point]
	if not tem == 0:
		flag = False
if flag:
	print('Yes')
else:
	print('No')


class UnionFind:

	def __init__(self, n: int):
		self.parent = [i for i in range(n + 1)]
		self.rank = [0] * (n + 1)

	def find(self, x: int) -> int:
		if self.parent[x] == x:
			return x
		else:
			self.parent[x] = self.find(self.parent[x])
			return self.parent[x]

	def unit(self, x: int, y: int):
		parent_x = self.find(x)
		parent_y = self.find(y)
		if self.rank[parent_x] < self.rank[parent_y]:
			self.parent[parent_x] = parent_y
		else:
			self.parent[parent_y] = parent_x
			if self.rank[parent_y] == self.rank[parent_x]:
				self.rank[parent_x] += 1

	def same_check(self, x: int, y: int) -> bool:
		return self.find(x) == self.find(y)
(N, M) = list(map(int, input().split()))
Als = list(map(int, input().split()))
Bls = list(map(int, input().split()))
uf = UnionFind(N)
for i in range(M):
	(c, d) = list(map(int, input().split()))
	uf.unit(c, d)
after_als = [0] * N
after_bls = [0] * N
for i in range(N):
	after_als[uf.find(i + 1) - 1] += Als[i]
	after_bls[uf.find(i + 1) - 1] += Bls[i]
for i in range(N):
	if after_als[i] != after_bls[i]:
		print('No')
		return
print('Yes')


import sys
from collections import defaultdict

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

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

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

def IR(n):
	return [I() for i in range(n)]

def LIR(n):
	return [LI() for i in range(n)]

def SR(n):
	return [S() for i in range(n)]

def S():
	return input()

def LS():
	return input().split()
INF = float('inf')

class UnionFind:

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

	def r(self, x):
		if self.root[x] < 0:
			return x
		else:
			self.root[x] = self.r(self.root[x])
			return self.root[x]

	def union(self, x, y):
		x = self.r(x)
		y = self.r(y)
		if x == y:
			return
		self.root[x] += self.root[y]
		self.root[y] = x

	def find(self, x, y) -> bool:
		return self.root[x] == self.root[y]

	def size(self, x) -> int:
		x = self.r(x)
		return -self.root[x]

	def members(self, x):
		root = self.r(x)
		return [i for i in range(self.n) if self.r(i) == root]

	def all_group_members(self):
		group_members = defaultdict(list)
		for member in range(self.n):
			group_members[self.r(member)].append(member)
		return group_members
(n, m) = LI()
a = LI()
b = LI()
uf = UnionFind(n)
for _ in range(m):
	(c, d) = LI()
	c -= 1
	d -= 1
	uf.union(c, d)
is_ok = True
mems = list(uf.all_group_members().values())
for mem in mems:
	a_sum = 0
	b_sum = 0
	for j in mem:
		a_sum += a[j]
		b_sum += b[j]
	if a_sum != b_sum:
		is_ok = False
		break
print('Yes' if is_ok else 'No')


class UnionFind:

	def __init__(self, n):
		self.N = n
		self.parent = [i for i in range(n)]
		self.rank = [0 for _ in range(n)]

	def root(self, x):
		visited_nodes = []
		while True:
			p = self.parent[x]
			if p == x:
				for node in visited_nodes:
					self.parent[node] = x
				return x
			else:
				visited_nodes.append(x)
				x = p

	def unite(self, x, y):
		if not self.root(x) == self.root(y):
			if self.rank[x] > self.rank[y]:
				self.parent[self.root(y)] = self.root(x)
			else:
				self.parent[self.root(x)] = self.root(y)
				if self.rank[x] == self.rank[y]:
					self.rank[self.root(y)] += 1

	def ifSame(self, x, y):
		return self.root(x) == self.root(y)

	def printDebugInfo(self):
		print([self.root(i) for i in range(self.N)])

	def seikei(self):
		for i in range(self.N):
			self.root(i)
(N, M) = list(map(int, input().split()))
tree = UnionFind(N)
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
for _ in range(M):
	(c, d) = list(map(int, input().split()))
	tree.unite(c - 1, d - 1)
tree.seikei()
gruops = {}
for (i, x) in enumerate(tree.parent):
	if x in gruops:
		gruops[x].append(i)
	else:
		gruops[x] = [i]
for k in list(gruops.keys()):
	a_total = 0
	b_total = 0
	for x in gruops[k]:
		a_total += A[x]
		b_total += B[x]
	if not a_total == b_total:
		print('No')
		return
print('Yes')


(n, m) = map(int, input().split())
ans = [list(map(int, input().split())) for i in range(2)]
l = [[] for i in range(n)]
for i in range(m):
	(a, b) = map(int, input().split())
	l[a - 1].append(b - 1)
	l[b - 1].append(a - 1)
boo = [-1] * n
flag = 0
from collections import deque
for i in range(n):
	if boo[i] == -1:
		q = deque([])
		q.append(i)
		ma = 0
		wa = 0
		while q:
			a = q.popleft()
			if boo[a] == -1:
				boo[a] += 1
				ma += ans[0][a]
				wa += ans[1][a]
				for j in l[a]:
					q.append(j)
		if ma != wa:
			flag = 1
			break
if flag == 0:
	print('Yes')
else:
	print('No')


class UnionFind:

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

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

	def union(self, x, y):
		x = self.find(x)
		y = self.find(y)
		if x == y:
			return
		if self.parents[x] > self.parents[y]:
			(x, y) = (y, x)
		self.parents[x] += self.parents[y]
		self.parents[y] = x

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

	def roots(self):
		return [i for (i, x) in enumerate(self.parents) if x < 0]

	def members(self, x):
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i) == root]

	def num_members(self, x):
		return abs(self.parents[self.find(x)])

	def groups(self):
		r_to_g = {}
		cnt = 0
		groups = []
		for i in range(self.n):
			r = self.find(i)
			if r not in r_to_g:
				groups.append([i])
				r_to_g[r] = cnt
				cnt += 1
			else:
				groups[r_to_g[r]].append(i)
		return groups
import sys, os, io
input = sys.stdin.readline
(N, M) = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
uf = UnionFind(N)
for i in range(M):
	(c, d) = map(int, input().split())
	uf.union(c - 1, d - 1)
for g in uf.groups():
	cnt = 0
	for v in g:
		cnt += A[v] - B[v]
	if cnt != 0:
		print('No')
		return
print('Yes')


class UnionFind:

	def __init__(self, size):
		self.data = [-1] * size

	def root(self, x):
		if self.data[x] < 0:
			return x
		ans = self.root(self.data[x])
		self.data[x] = ans
		return ans

	def unite(self, x, y):
		x = self.root(x)
		y = self.root(y)
		if x == y:
			return False
		if self.data[x] > self.data[y]:
			(x, y) = (y, x)
		self.data[x] += self.data[y]
		self.data[y] = x
		return True

	def same(self, x, y):
		return self.root(x) == self.root(y)
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
uf = UnionFind(n)
for _ in range(m):
	(c, d) = map(int, input().split())
	c -= 1
	d -= 1
	uf.unite(c, d)
l = [0] * n
for i in range(n):
	p = uf.root(i)
	l[p] += a[i]
	l[p] -= b[i]
if all([x == 0 for x in l]):
	print('Yes')
else:
	print('No')


import sys
input = sys.stdin.readline

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

def inps():
	return input().rstrip()

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

def inpls():
	return list(map(str, input().split()))
from math import gcd, floor, ceil, factorial
import itertools as it
from collections import deque, defaultdict
from collections import Counter

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

def chmin(dp, i, x):
	if x < dp[i]:
		dp[i] = x
		return True
	return False

def chmax(dp, i, x):
	if x > dp[i]:
		dp[i] = x
		return True
	return False

class UnionFind:

	def __init__(self, num):
		self.parent = [i for i in range(num)]
		self.size = [1] * num

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

	def unite(self, x, y):
		x = self.find(x)
		y = self.find(y)
		if x == y:
			return
		else:
			if self.size[x] < self.size[y]:
				(x, y) = (y, x)
			self.parent[y] = x
			self.size[x] += 1

	def roots(self):
		st = set()
		for i in self.parent:
			st.add(i)
		return list(st)
(N, M) = inpl()
a = inpl()
b = inpl()
uf = UnionFind(N)
for i in range(M):
	(c, d) = inpl()
	c -= 1
	d -= 1
	uf.unite(c, d)
mp = dict()
for i in uf.roots():
	mp[i] = 0
for i in range(N):
	group = uf.find(i)
	mp[group] += a[i] - b[i]
bl = True
for (k, v) in list(mp.items()):
	if v != 0:
		bl = False
		break
print('Yes' if bl else 'No')


from collections import defaultdict

class UnionFind:

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

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

	def union(self, x, y):
		x = self.find(x)
		y = self.find(y)
		if x == y:
			return
		if self.parents[x] > self.parents[y]:
			(x, y) = (y, x)
		self.parents[x] += self.parents[y]
		self.parents[y] = x

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

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

	def members(self, x):
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i) == root]

	def roots(self):
		return [i for (i, x) in enumerate(self.parents) if x < 0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		group_members = defaultdict(list)
		for member in range(self.n):
			group_members[self.find(member)].append(member)
		return group_members

	def __str__(self):
		return '\n'.join((f'{r}: {m}' for (r, m) in list(self.all_group_members().items())))
(n, m) = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
uf = UnionFind(n)
for i in range(m):
	(c, d) = list(map(int, input().split()))
	uf.union(c - 1, d - 1)
for i in list(uf.all_group_members().values()):
	s1 = 0
	s2 = 0
	for j in i:
		s1 += a[j]
		s2 += b[j]
	if s1 != s2:
		print('No')
		return
print('Yes')


class Union_Find:

	def __init__(self, N):
		self.n = N
		self.parents = [-1] * N
		self.rank = [0] * N

	def find(self, x):
		V = []
		while self.parents[x] >= 0:
			V.append(x)
			x = self.parents[x]
		for v in V:
			self.parents[v] = x
		return x

	def union(self, x, y):
		x = self.find(x)
		y = self.find(y)
		if x == y:
			return
		if self.rank[x] > self.rank[y]:
			self.parents[x] += self.parents[y]
			self.parents[y] = x
		else:
			self.parents[y] += self.parents[x]
			self.parents[x] = y
			if self.rank[x] == self.rank[y]:
				self.rank[y] += 1

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

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

	def members(self, x):
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i) == root]

	def roots(self):
		return [i for (i, x) in enumerate(self.parents) if x < 0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		X = {r: [] for r in self.roots()}
		for k in range(self.n):
			X[self.find(k)].append(k)
		return X

	def __str__(self):
		return '\n'.join(('{}: {}'.format(r, self.members(r)) for r in self.roots()))
import sys
input = sys.stdin.readline
(N, M) = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
U = Union_Find(N)
for _ in range(M):
	(c, d) = map(int, input().split())
	U.union(c - 1, d - 1)
H = U.all_group_members()
F = True
for g in H:
	X = Y = 0
	for u in H[g]:
		X += A[u]
		Y += B[u]
	F = F & (X == Y)
if F:
	print('Yes')
else:
	print('No')


from collections import defaultdict

class UnionFind:

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

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

	def union(self, x, y):
		x = self.find(x)
		y = self.find(y)
		if x == y:
			return
		if self.parents[x] > self.parents[y]:
			(x, y) = (y, x)
		self.parents[x] += self.parents[y]
		self.parents[y] = x

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

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

	def members(self, x):
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i) == root]

	def roots(self):
		return [i for (i, x) in enumerate(self.parents) if x < 0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		group_members = defaultdict(list)
		for member in range(self.n):
			group_members[self.find(member)].append(member)
		return group_members

	def __str__(self):
		return '\n'.join((f'{r}: {m}' for (r, m) in self.all_group_members().items()))
(N, M) = map(int, input().split())
alist = list(map(int, input().split()))
blist = list(map(int, input().split()))
uf = UnionFind(N)
for i in range(M):
	(C, D) = map(int, input().split())
	uf.union(C - 1, D - 1)
a = [0] * N
b = [0] * N
for i in range(N):
	a[uf.find(i)] += alist[i]
	b[uf.find(i)] += blist[i]
if a == b:
	print('Yes')
else:
	print('No')


import sys, math, random, re, heapq
from itertools import combinations as c, permutations as perm, product as p
from collections import deque
from copy import deepcopy
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

def si():
	return input()

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

def fi():
	return float(input())

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

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

def lintdec():
	return list(map(lambda x: int(x) - 1, input().split()))

def lnstr(n):
	return [input() for _ in range(n)]

def lnint(n):
	return [ii() for _ in range(n)]

def lint_list(n):
	return [lint() for _ in range(n)]

def lcm(a, b):
	return a * b // math.gcd(a, b)
(N, M) = lint()

class UnionFind:

	def __init__(self):
		self.par = [0] * N
		self.rank = [0] * N
		for i in range(N):
			self.par[i] = i

	def root(self, x):
		if self.par[x] == x:
			return x
		parx = self.root(self.par[x])
		self.par[x] = parx
		return parx

	def unite(self, x, y):
		x = self.root(x)
		y = self.root(y)
		if x == y:
			return
		if self.rank[x] < self.rank[y]:
			self.par[x] = y
		else:
			self.par[y] = x
			if self.rank[x] == self.rank[y]:
				self.rank[x] += 1

def main():
	UF = UnionFind()
	a = lint()
	b = lint()
	for _ in range(M):
		(c, d) = lintdec()
		UF.unite(c, d)
	roots = [UF.root(i) for i in range(N)]
	sum_a = {root: 0 for root in set(roots)}
	sum_b = sum_a.copy()
	for i in range(N):
		sum_a[roots[i]] += a[i]
		sum_b[roots[i]] += b[i]
	print('Yes' if sum_a == sum_b else 'No')

def __starting_point():
	main()
__starting_point()


import sys
from functools import reduce
zz = 1
sys.setrecursionlimit(10 ** 5)
if zz:
	input = sys.stdin.readline
else:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('all.txt', 'w')
di = [[-1, 0], [1, 0], [0, 1], [0, -1]]

def fori(n):
	return [fi() for i in range(n)]

def inc(d, c, x=1):
	d[c] = d[c] + x if c in d else x

def ii():
	return input().rstrip()

def li():
	return [int(xx) for xx in input().split()]

def fli():
	return [float(x) for x in input().split()]

def comp(a, b):
	if a > b:
		return 2
	return 2 if a == b else 0

def gi():
	return [xx for xx in input().split()]

def gtc(tc, ans):
	print(('Case #' + str(tc) + ':', ans))

def cil(n, m):
	return n // m + int(n % m > 0)

def fi():
	return int(input())

def pro(a):
	return reduce(lambda a, b: a * b, a)

def swap(a, i, j):
	(a[i], a[j]) = (a[j], a[i])

def si():
	return list(input().rstrip())

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

def gh():
	sys.stdout.flush()

def isvalid(i, j, n, m):
	return 0 <= i < n and 0 <= j < m

def bo(i):
	return ord(i) - ord('a')

def graph(n, m):
	for i in range(m):
		(x, y) = mi()
		a[x].append(y)
		a[y].append(x)
t = 1
uu = t

def find(i):
	if i == a[i]:
		return i
	a[i] = find(a[i])
	return a[i]

def union(x, y):
	(xs, ys) = (find(x), find(y))
	if xs != ys:
		if rank[xs] < rank[ys]:
			(xs, ys) = (ys, xs)
		a[ys] = xs
		rank[xs] += 1
		return False
	return True
while t > 0:
	t -= 1
	(n, m) = mi()
	a = [i for i in range(n + 1)]
	rank = [0] * (n + 1)
	c = li()
	d = li()
	for i in range(m):
		(x, y) = mi()
		union(x, y)
	p = [0] * (n + 1)
	for i in range(n):
		a[i + 1] = find(i + 1)
		p[a[i + 1]] += c[i] - d[i]
	print('Yes' if p.count(0) == len(p) else 'No')


from collections import deque
(N, M) = list(map(int, input().split()))
a = tuple(map(int, input().split()))
b = tuple(map(int, input().split()))
graph = [[] for i in range(N)]
for i in range(M):
	(c, d) = list(map(int, input().split()))
	graph[c - 1].append(d - 1)
	graph[d - 1].append(c - 1)
graph = tuple((tuple(l) for l in graph))
unreached = set(range(N))
queue = deque()
judge = 'Yes'
while len(unreached) > 0:
	node = unreached.pop()
	queue.append(node)
	sum_a = a[node]
	sum_b = b[node]
	while len(queue) > 0:
		for node in graph[queue.pop()]:
			if node in unreached:
				unreached.remove(node)
				queue.append(node)
				sum_a += a[node]
				sum_b += b[node]
	if sum_a != sum_b:
		judge = 'No'
		break
print(judge)


class UnionFind:

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

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

	def union(self, x, y):
		x = self.find(x)
		y = self.find(y)
		if x == y:
			return
		if self.parents[x] > self.parents[y]:
			(x, y) = (y, x)
		self.parents[x] += self.parents[y]
		self.parents[y] = x

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

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

	def members(self, x):
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i) == root]

	def roots(self):
		return [i for (i, x) in enumerate(self.parents) if x < 0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()}

	def __str__(self):
		return '\n'.join(('{}: {}'.format(r, self.members(r)) for r in self.roots()))
(N, M) = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
uf = UnionFind(N)
for _ in range(M):
	(c, d) = map(int, input().split())
	uf.union(c - 1, d - 1)
root_Asum = [0] * N
root_Bsum = [0] * N
for i in range(N):
	now_root = uf.find(i)
	root_Asum[now_root] += A[i]
	root_Bsum[now_root] += B[i]
for (a_sum, b_sum) in zip(root_Asum, root_Bsum):
	if a_sum != b_sum:
		print('No')
		return
print('Yes')


import collections
import itertools
import operator

class UnionFind:

	def __init__(self, elems=None):

		class KeyDict(dict):

			def __missing__(self, key):
				self[key] = key
				return key
		self.parent = KeyDict()
		self.rank = collections.defaultdict(int)
		if elems is not None:
			for elem in elems:
				(_, _) = (self.parent[elem], self.rank[elem])

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

	def unite(self, x, y):
		x = self.find(x)
		y = self.find(y)
		if self.rank[x] < self.rank[y]:
			self.parent[x] = y
		else:
			self.parent[y] = x
		if self.rank[x] == self.rank[y]:
			self.rank[x] += 1

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

	def grouper(self):
		roots = [(x, self.find(x_par)) for (x, x_par) in self.parent.items()]
		root = operator.itemgetter(1)
		for (_, group) in itertools.groupby(sorted(roots, key=root), root):
			yield [x for (x, _) in group]
(N, M) = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
uf = UnionFind()
for m in range(M):
	(n1, n2) = list(map(int, input().split()))
	uf.unite(n1, n2)
for n in range(N):
	n = n + 1
	uf.unite(n, n)
ans = 'Yes'
for g_nodes in list(uf.grouper()):
	a_sum = 0
	b_sum = 0
	for node in g_nodes:
		a_sum += A[node - 1]
		b_sum += B[node - 1]
	if a_sum != b_sum:
		ans = 'No'
print(ans)


class UnionFind:

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

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

	def union(self, x, y):
		x = self.find(x)
		y = self.find(y)
		if x == y:
			return
		if self.parents[x] > self.parents[y]:
			(x, y) = (y, x)
		self.parents[x] += self.parents[y]
		self.parents[y] = x

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

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

	def members(self, x):
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i) == root]

	def all_group_members(self):
		self.group = {r: [] for r in self.roots()}
		for i in range(self.n):
			self.group[self.find(i)].append(i)
		return self.group

	def roots(self):
		return [i for (i, x) in enumerate(self.parents) if x < 0]

	def group_count(self):
		return len(self.roots())

	def __str__(self):
		return '\n'.join(('{}: {}'.format(k, v) for (k, v) in list(self.all_group_members().items())))
(n, m) = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
CD = [list(map(int, input().split())) for _ in range(m)]
uf = UnionFind(n)
for (c, d) in CD:
	uf.union(c - 1, d - 1)
for (key, val) in list(uf.all_group_members().items()):
	if sum((A[i] for i in val)) != sum((B[i] for i in val)):
		print('No')
		return
print('Yes')


class UnionFind:

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

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

	def union(self, x, y):
		x = self.find(x)
		y = self.find(y)
		if x == y:
			return
		if self.parents[x] > self.parents[y]:
			(x, y) = (y, x)
		self.parents[x] += self.parents[y]
		self.parents[y] = x

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

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

	def members(self, x):
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i) == root]

	def roots(self):
		return [i for (i, x) in enumerate(self.parents) if x < 0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()}

	def __str__(self):
		return '\n'.join(('{}: {}'.format(r, self.members(r)) for r in self.roots()))
(N, M) = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
uf = UnionFind(N)
for _ in range(M):
	(c, d) = map(int, input().split())
	uf.union(c - 1, d - 1)
samu1 = [0] * N
samu2 = [0] * N
for i in range(N):
	r = uf.find(i)
	samu1[r] += A[i]
	samu2[r] += B[i]
for i in range(N):
	if samu1[i] != samu2[i]:
		print('No')
		break
else:
	print('Yes')


from collections import defaultdict as dd

class UnionFind:

	def __init__(self, n):
		self.n = n
		self.root = [-1] * n
		self.rank = [0] * n

	def find(self, x):
		if self.root[x - 1] < 0:
			return x
		else:
			self.root[x - 1] = self.find(self.root[x - 1])
			return self.root[x - 1]

	def unite(self, x, y):
		x = self.find(x)
		y = self.find(y)
		if x == y:
			return
		elif self.rank[x - 1] > self.rank[y - 1]:
			self.n -= 1
			self.root[x - 1] += self.root[y - 1]
			self.root[y - 1] = x
		else:
			self.n -= 1
			self.root[y - 1] += self.root[x - 1]
			self.root[x - 1] = y
			if self.rank[x - 1] == self.rank[y - 1]:
				self.rank[y - 1] += 1

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

	def count(self, x):
		return -self.root[self.find(x) - 1]

	def size(self):
		return self.n

def main():
	(n, m) = map(int, input().split())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	uf = UnionFind(n)
	for _ in range(m):
		uf.unite(*map(int, input().split()))
	s = dd(int)
	t = dd(int)
	for i in range(n):
		ii = uf.find(i + 1)
		s[ii] += A[i]
		t[ii] += B[i]
	for k in s.keys():
		if s[k] == t[k]:
			continue
		else:
			print('No')
			break
	else:
		print('Yes')
main()


import sys
readline = sys.stdin.readline
(N, M) = list(map(int, readline().split()))
A = list(map(int, readline().split()))
B = list(map(int, readline().split()))
G = [[] for i in range(N)]
for i in range(M):
	(c, d) = list(map(int, readline().split()))
	G[c - 1].append(d - 1)
	G[d - 1].append(c - 1)
seen = set()
for i in range(N):
	if i in seen:
		continue
	stack = [i]
	a_sum = 0
	b_sum = 0
	while stack:
		v = stack.pop()
		if v in seen:
			continue
		seen.add(v)
		a_sum += A[v]
		b_sum += B[v]
		for child in G[v]:
			stack.append(child)
	if a_sum != b_sum:
		print('No')
		break
else:
	print('Yes')


import sys
input = sys.stdin.readline
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
diff = [0] * n
for ii in range(n):
	diff[ii] = b[ii] - a[ii]
parent = list(range(n))
rank = [0] * n

def findroot(x):
	if parent[x] != x:
		parent[x] = findroot(parent[x])
	return parent[x]

def unite(x, y):
	x = findroot(x)
	y = findroot(y)
	if x != y:
		if rank[x] == rank[y]:
			parent[y] = x
			rank[x] += 1
		elif rank[x] < rank[y]:
			parent[x] = y
		else:
			parent[y] = x
	return
for _ in range(m):
	(x, y) = map(int, input().split())
	unite(x - 1, y - 1)
r = [-1] * n
for ii in range(n):
	r[ii] = findroot(ii)
sum = [0] * n
for (ii, rr) in enumerate(r):
	sum[rr] += diff[ii]
for ii in sum:
	if ii:
		print('No')
		return
print('Yes')


from collections import defaultdict

class UnionFind:

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

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

	def union(self, x, y):
		x = self.find(x)
		y = self.find(y)
		if x == y:
			return
		if self.parents[x] > self.parents[y]:
			(x, y) = (y, x)
		self.parents[x] += self.parents[y]
		self.parents[y] = x

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

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

	def members(self, x):
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i) == root]

	def roots(self):
		return [i for (i, x) in enumerate(self.parents) if x < 0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		group_members = defaultdict(list)
		for member in range(self.n):
			group_members[self.find(member)].append(member)
		return group_members

	def __str__(self):
		return '\n'.join((f'{r}: {m}' for (r, m) in list(self.all_group_members().items())))
(N, M) = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
res = []
for i in range(N):
	res.append(A[i] - B[i])
uf = UnionFind(N)
for i in range(M):
	(c, d) = list(map(int, input().split()))
	uf.union(c - 1, d - 1)
flag = True
sa = {}
sb = {}
for i in range(N):
	r = uf.find(i)
	if r not in list(sa.keys()):
		sa[r] = A[i]
		sb[r] = B[i]
	else:
		sa[r] += A[i]
		sb[r] += B[i]
for k in list(sa.keys()):
	if sa[k] != sb[k]:
		flag = False
print('Yes' if flag else 'No')


from collections import deque
(N, M) = map(int, input().split())
A = list(map(int, input().split()))
A.insert(0, 0)
B = list(map(int, input().split()))
B.insert(0, 0)
G = {i: [] for i in range(1, N + 1)}
for _ in range(M):
	(c, d) = map(int, input().split())
	G[c].append(d)
	G[d].append(c)
Col = [-1 for _ in range(N + 1)]
cnt = 0
for i in range(1, N + 1):
	if Col[i] < 0:
		que = deque([i])
		Col[i] = cnt
		while que:
			x = que.popleft()
			for y in G[x]:
				if Col[y] < 0:
					Col[y] = cnt
					que.append(y)
		cnt += 1
Mem = {c: [] for c in range(cnt)}
for i in range(1, N + 1):
	Mem[Col[i]].append(i)
flag = 0
for c in Mem:
	c1 = 0
	c2 = 0
	for i in Mem[c]:
		c1 += A[i]
		c2 += B[i]
	if c1 != c2:
		flag = 1
		break
if flag == 0:
	print('Yes')
else:
	print('No')


import typing

class DSU:

	def __init__(self, n: int=0) -> None:
		self._n = n
		self.parent_or_size = [-1] * n

	def merge(self, a: int, b: int) -> int:
		assert 0 <= a < self._n
		assert 0 <= b < self._n
		x = self.leader(a)
		y = self.leader(b)
		if x == y:
			return x
		if -self.parent_or_size[x] < -self.parent_or_size[y]:
			(x, y) = (y, x)
		self.parent_or_size[x] += self.parent_or_size[y]
		self.parent_or_size[y] = x
		return x

	def same(self, a: int, b: int) -> bool:
		assert 0 <= a < self._n
		assert 0 <= b < self._n
		return self.leader(a) == self.leader(b)

	def leader(self, a: int) -> int:
		assert 0 <= a < self._n
		parent = self.parent_or_size[a]
		while parent >= 0:
			if self.parent_or_size[parent] < 0:
				return parent
			(self.parent_or_size[a], a, parent) = (self.parent_or_size[parent], self.parent_or_size[parent], self.parent_or_size[self.parent_or_size[parent]])
		return a

	def size(self, a: int) -> int:
		assert 0 <= a < self._n
		return -self.parent_or_size[self.leader(a)]

	def groups(self) -> typing.List[typing.List[int]]:
		leader_buf = [self.leader(i) for i in range(self._n)]
		result: typing.List[typing.List[int]] = [[] for _ in range(self._n)]
		for i in range(self._n):
			result[leader_buf[i]].append(i)
		return list(filter(lambda r: r, result))
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
cd = [list(map(int, input().split())) for _ in range(m)]
uf = DSU(n)
for (c, d) in cd:
	uf.merge(c - 1, d - 1)
for i in uf.groups():
	x = 0
	y = 0
	for j in i:
		x += a[j]
		y += b[j]
	if x != y:
		print('No')
		return
print('Yes')


import queue
(N, M) = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
nds = [[] for _ in range(N)]
vstd = [False for _ in range(N)]
ans = 'Yes'
for i in range(M):
	(c, d) = map(int, input().split())
	c -= 1
	d -= 1
	nds[c].append(d)
	nds[d].append(c)
for i in range(N):
	if vstd[i]:
		continue
	q = queue.Queue()
	q.put(i)
	vstd[i] = True
	a = 0
	b = 0
	while not q.empty():
		idx = q.get()
		a += A[idx]
		b += B[idx]
		for e in nds[idx]:
			if vstd[e]:
				continue
			vstd[e] = True
			q.put(e)
	if a != b:
		ans = 'No'
print(ans)


(n, m) = list(map(int, input().split()))
g = [[] for _ in range(n)]
a = list(map(int, input().split()))
b = list(map(int, input().split()))
for _ in range(m):
	(x, y) = list(map(int, input().split()))
	x -= 1
	y -= 1
	g[x].append(y)
	g[y].append(x)
visited = [0] * n
for i in range(n):
	if not visited[i]:
		stack = [i]
		curr = 0
		visited[i] = 1
		while stack:
			node = stack.pop()
			curr += a[node] - b[node]
			for j in g[node]:
				if not visited[j]:
					visited[j] = 1
					stack.append(j)
		if curr:
			print('No')
			return
print('Yes')


from collections import deque
(n, m) = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
G = [[] for _ in range(n)]
for i in range(m):
	(i, j) = map(int, input().split())
	i -= 1
	j -= 1
	G[i].append(j)
	G[j].append(i)
seen = [False] * n
que = deque()
for i in range(n):
	if not seen[i]:
		que.append(i)
		seen[i] = True
		(a, b) = (0, 0)
		while len(que):
			v = que.popleft()
			a += A[v]
			b += B[v]
			for nv in G[v]:
				if not seen[nv]:
					que.append(nv)
					seen[nv] = True
		if a != b:
			print('No')
			return
print('Yes')


from collections import defaultdict

class UnionFind:

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

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

	def union(self, x, y):
		x = self.find(x)
		y = self.find(y)
		if x == y:
			return
		if self.parents[x] > self.parents[y]:
			(x, y) = (y, x)
		self.parents[x] += self.parents[y]
		self.parents[y] = x

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

	def roots(self):
		return [i for (i, x) in enumerate(self.parents) if x < 0]

	def members(self, x):
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i) == root]

	def num_members(self, x):
		return abs(self.parents[self.find(x)])

	def groups(self):
		roots = self.roots()
		r_to_i = {}
		for (i, r) in enumerate(roots):
			r_to_i[r] = i
		groups = [[] for _ in roots]
		for i in range(self.n):
			groups[r_to_i[self.find(i)]].append(i)
		return groups
(N, M) = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
uf = UnionFind(N)
for i in range(M):
	(c, d) = list(map(int, input().split()))
	uf.union(c - 1, d - 1)
for g in uf.groups():
	cnt = 0
	for v in g:
		cnt += A[v] - B[v]
	if cnt != 0:
		print('No')
		return
print('Yes')


class UnionFind:

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

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

	def union(self, x, y):
		x = self.find(x)
		y = self.find(y)
		if x == y:
			return
		if self.parents[x] > self.parents[y]:
			(x, y) = (y, x)
		self.parents[x] += self.parents[y]
		self.parents[y] = x
		return x

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

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

	def members(self, x):
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i) == root]

	def roots(self):
		return [i for (i, x) in enumerate(self.parents) if x < 0]

	def group_count(self):
		return len(self.roots())

	def group_sizes(self):
		return [uf.size(x) for x in uf.roots()]

	def all_group_members(self):
		group = {r: [] for r in self.roots()}
		for i in range(self.n):
			group[self.find(i)].append(i)
		return list(group.values())

	def __str__(self):
		return '\n'.join(('{}: {}'.format(r, self.members(r)) for r in self.roots()))
(N, M) = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
CD = [[int(i) for i in input().split()] for j in range(M)]
uf = UnionFind(N)
for (c, d) in CD:
	uf.union(c - 1, d - 1)
gr = uf.all_group_members()
for g in gr:
	asum = sum([A[i] for i in g])
	bsum = sum([B[i] for i in g])
	if asum != bsum:
		print('No')
		return
print('Yes')


from collections import deque
(n, m) = map(int, input().split())
a = tuple(map(int, input().split()))
b = tuple(map(int, input().split()))
g = [[] for _ in range(n)]
for _ in range(m):
	(i, j) = map(lambda x: int(x) - 1, input().split())
	g[i].append(j)
	g[j].append(i)
c = [False] * n
ans = 'Yes'
for i in range(n):
	if c[i]:
		continue
	c[i] = True
	da = a[i]
	db = b[i]
	q = deque(g[i])
	while q:
		j = q.popleft()
		if c[j]:
			continue
		c[j] = True
		da += a[j]
		db += b[j]
		for k in g[j]:
			q.append(k)
	if da != db:
		ans = 'No'
		break
print(ans)


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

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

def NL(n):
	return [list(map(int, input().split())) for i in range(n)]
mod = pow(10, 9) + 7
import sys
sys.setrecursionlimit(2147483647)
import math
from itertools import accumulate
from itertools import permutations
from collections import Counter
from collections import deque
from collections import defaultdict
import bisect
import heapq
inf = float('inf')
dic = defaultdict(lambda : 0)

class UnionFind:
	par = []
	rank = []

	def __init__(self, n):
		for i in range(n):
			self.par.append(i)
			self.rank.append(0)

	def root(self, x):
		if self.par[x] == x:
			return x
		else:
			self.par[x] = self.root(self.par[x])
			return self.par[x]

	def same(self, x, y):
		if self.root(x) == self.root(y):
			return True
		else:
			return False

	def unite(self, x, y):
		x = self.root(x)
		y = self.root(y)
		if x == y:
			return
		if self.rank[x] > self.rank[y]:
			self.par[y] = x
		else:
			self.par[x] = y
			if self.rank[x] == self.rank[y]:
				self.rank[y] += 1

	def comp(self):
		for i in range(len(self.par)):
			self.root(i)
(n, m) = L()
a = L()
b = L()
cd = NL(m)
uf = UnionFind(n)
for (c, d) in cd:
	uf.unite(c - 1, d - 1)
uf.comp()
va = defaultdict(int)
vb = defaultdict(int)
for i in range(n):
	va[uf.par[i]] += a[i]
	vb[uf.par[i]] += b[i]
for i in range(n):
	if va[i] != vb[i]:
		print('No')
		break
else:
	print('Yes')


class UnionFind:

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

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

	def union(self, x, y):
		x = self.find(x)
		y = self.find(y)
		if x == y:
			return
		if self.parents[x] > self.parents[y]:
			(x, y) = (y, x)
		self.parents[x] += self.parents[y]
		self.parents[y] = x
		return x

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

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

	def members(self, x):
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i) == root]

	def roots(self):
		return [i for (i, x) in enumerate(self.parents) if x < 0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()}

	def __str__(self):
		return '\n'.join(('{}: {}'.format(r, self.members(r)) for r in self.roots()))
from collections import defaultdict

def main():
	(N, M) = list(map(int, input().split()))
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	A.append(0)
	B.append(0)
	uf = UnionFind(N + 1)
	for _ in range(M):
		(c, d) = list(map(int, input().split()))
		uf.union(c, d)
	A_sums = defaultdict(int)
	B_sums = defaultdict(int)
	for i in range(1, N + 1):
		x = uf.find(i)
		A_sums[x] += A[i - 1]
		B_sums[x] += B[i - 1]
	for (a, b) in zip(list(A_sums.values()), list(B_sums.values())):
		if a != b:
			print('No')
			return
	print('Yes')
main()


from collections import defaultdict

class UnionFind:

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

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

	def union(self, x, y):
		x = self.find(x)
		y = self.find(y)
		if x == y:
			return
		if self.parents[x] > self.parents[y]:
			(x, y) = (y, x)
		self.parents[x] += self.parents[y]
		self.parents[y] = x

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

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

	def members(self, x):
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i) == root]

	def roots(self):
		return [i for (i, x) in enumerate(self.parents) if x < 0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		group_members = defaultdict(list)
		for member in range(self.n):
			group_members[self.find(member)].append(member)
		return group_members

	def __str__(self):
		return '\n'.join((f'{r}: {m}' for (r, m) in self.all_group_members().items()))
(N, M) = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = [0] * N
for i in range(N):
	C[i] = A[i] - B[i]
uf = UnionFind(N)
for i in range(M):
	(A, B) = map(int, input().split())
	uf.union(A - 1, B - 1)
M = uf.all_group_members()
ans = True
for v in M.values():
	su = 0
	for c in v:
		su += C[c]
	ans = ans and su == 0
if ans:
	print('Yes')
else:
	print('No')


(n, m) = map(int, input().rstrip().split(' '))
A = list(map(int, input().rstrip().split(' ')))
B = list(map(int, input().rstrip().split(' ')))
M = []
for i in range(m):
	(a, b) = map(int, input().rstrip().split(' '))
	M.append((a - 1, b - 1))

class UnionFind:
	Par = []
	Total = []

	def __init__(self, n_):
		for i in range(n_):
			self.Par.append(i)
			self.Total.append(0)

	def root(self, x):
		if self.Par[x] == x:
			ret = x
		else:
			ret = self.root(self.Par[x])
		return ret

	def unite(self, x, y):
		x = self.root(x)
		y = self.root(y)
		if x > y:
			self.Par[x] = y
		elif x < y:
			self.Par[y] = x

	def same(x, y):
		x = self.root(x)
		y = self.root(y)
		if x == y:
			ret = True
		else:
			ret = False
		return ret

	def printf(self):
		print(self.Par)
		print(self.Total)
union = UnionFind(n)
for i in M:
	(c, d) = i
	union.unite(c, d)
Dif = []
for i in range(n):
	dif = B[i] - A[i]
	Dif.append(dif)
Zero = [0 for i in range(n)]
for i in range(n):
	root = union.root(i)
	Zero[root] += Dif[i]
isOK = True
for zero in Zero:
	if zero != 0:
		isOK = False
if isOK == True:
	print('Yes')
else:
	print('No')


class UnionFind:

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

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

	def union(self, x, y):
		x = self.find(x)
		y = self.find(y)
		if x == y:
			return
		if self.parents[x] > self.parents[y]:
			(x, y) = (y, x)
		self.parents[x] += self.parents[y]
		self.parents[y] = x

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

	def roots(self):
		return [i for (i, x) in enumerate(self.parents) if x < 0]

	def members(self, x):
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i) == root]

	def size(self, x):
		return abs(self.parents[self.find(x)])

	def groups(self):
		roots = self.roots()
		r_to_g = {}
		for (i, r) in enumerate(roots):
			r_to_g[r] = i
		groups = [[] for _ in roots]
		for i in range(self.n):
			groups[r_to_g[self.find(i)]].append(i)
		return groups
(n, m) = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
uf = UnionFind(n)
for _ in range(m):
	(c, d) = list(map(int, input().split()))
	c -= 1
	d -= 1
	uf.union(c, d)
sa = [0] * (n + 1)
sb = [0] * (n + 1)
for i in range(n):
	par = uf.find(i)
	sa[par] += a[i]
	sb[par] += b[i]
for (aa, bb) in zip(sa, sb):
	if aa != bb:
		print('No')
		return
print('Yes')


from collections import defaultdict

def Yes_No(flag):
	if flag:
		print('Yes')
	else:
		print('No')

class UnionFind:

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

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

	def union(self, x, y):
		x = self.find(x)
		y = self.find(y)
		if x == y:
			return
		if self.parents[x] > self.parents[y]:
			(x, y) = (y, x)
		self.parents[x] += self.parents[y]
		self.parents[y] = x

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

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

	def members(self, x):
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i) == root]

	def roots(self):
		return [i for (i, x) in enumerate(self.parents) if x < 0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		group_members = defaultdict(list)
		for member in range(self.n):
			group_members[self.find(member)].append(member)
		return group_members

	def __str__(self):
		return '\n'.join((f'{r}: {m}' for (r, m) in self.all_group_members().items()))
(n, m) = list(map(int, input().split()))
aa = list(map(int, input().split()))
bb = list(map(int, input().split()))
cds = [list(map(int, input().split())) for _ in range(m)]
uf = UnionFind(n)
for i in range(m):
	(x, y) = cds[i]
	uf.union(x - 1, y - 1)
ans = True
for (key, val) in uf.all_group_members().items():
	if sum((aa[i] for i in val)) != sum((bb[i] for i in val)):
		ans = False
Yes_No(ans)


import collections
(N, M) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
l = [list(map(int, input().split())) for l in range(M)]
par = [i for i in range(N)]

def find(x):
	if par[x] == x:
		return x
	else:
		par[x] = find(par[x])
		return par[x]

def unite(x, y):
	x = find(x)
	y = find(y)
	if x == y:
		return 0
	par[x] = y
for i in l:
	unite(i[0] - 1, i[1] - 1)
for i in range(N):
	find(i)
c = collections.Counter(par)
sumcheck = [[0] * N, [0] * N]
for i in range(N):
	sumcheck[0][par[i]] += a[i]
	sumcheck[1][par[i]] += b[i]
if sumcheck[0] == sumcheck[1]:
	print('Yes')
else:
	print('No')


def root(x):
	if r[x] < 0:
		return x
	else:
		r[x] = root(r[x])
		return r[x]

def unite(x, y):
	x = root(x)
	y = root(y)
	if x != y:
		if r[x] > r[y]:
			(x, y) = (y, x)
		r[x] += r[y]
		r[y] = x
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
r = [-1] * n
for i in range(m):
	(c, d) = map(int, input().split())
	c -= 1
	d -= 1
	unite(c, d)
p = [0] * n
q = [0] * n
for i in range(n):
	if r[i] < 0:
		x = i
	else:
		x = root(i)
	p[x] += a[i]
	q[x] += b[i]
for i in range(n):
	if p[i] != q[i]:
		print('No')
		return
print('Yes')


from collections import defaultdict

class UnionFind:

	def __init__(self, size):
		self.parent = list(range(size))

	def find(self, i):
		while self.parent[i] != i:
			i = self.parent[i]
		return i

	def unite(self, i, j):
		(i, j) = (self.find(i), self.find(j))
		if i > j:
			(i, j) = (j, i)
		self.parent[j] = i
(n, m) = list(map(int, input().split()))
(*a,) = list(map(int, input().split()))
(*b,) = list(map(int, input().split()))
uf = UnionFind(n)
for _ in range(m):
	(x, y) = list(map(int, input().split()))
	uf.unite(x - 1, y - 1)
(sa, sb) = (defaultdict(int), defaultdict(int))
for i in range(n):
	sa[uf.find(i)] += a[i]
	sb[uf.find(i)] += b[i]
if all((sa[i] == sb[i] for i in sa)):
	print('Yes')
else:
	print('No')


import sys
sys.setrecursionlimit(10 ** 9)
read = lambda : sys.stdin.readline()
from collections import deque

def read_ints():
	return list(map(int, read().split()))

def read_intgrid(h):
	return list((list(map(int, read().split())) for i in range(h)))

def main():
	(n, m) = read_ints()
	A = read_ints()
	B = read_ints()
	G = [[] for _ in range(n)]
	for i in range(m):
		(c, d) = map(int, input().split())
		(c, d) = (c - 1, d - 1)
		G[c].append(d)
		G[d].append(c)
	ans = 1
	vis = [0] * n

	def bfs(v):
		queue = deque([v])
		vis[v] = 1
		tmp1 = A[v]
		tmp2 = B[v]
		while queue:
			x = queue.popleft()
			for y in G[x]:
				if vis[y]:
					continue
				tmp1 += A[y]
				tmp2 += B[y]
				vis[y] = 1
				queue.append(y)
		if tmp1 == tmp2:
			return True
		else:
			return False
	for i in range(n):
		if vis[i]:
			continue
		if not bfs(i):
			ans = 0
			break
	return print('Yes' if ans else 'No')

def __starting_point():
	main()
__starting_point()


import sys
sys.setrecursionlimit(1000000000)
(n, m) = map(int, input().split())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
G = [[] for _ in range(n)]
for _ in range(m):
	(c, d) = map(int, input().split())
	c -= 1
	d -= 1
	G[c].append(d)
	G[d].append(c)
seen = [False] * n

def dfs(now):
	seen[now] = True
	sa = A[now]
	sb = B[now]
	for nxt in G[now]:
		if seen[nxt]:
			continue
		seen[nxt] = True
		(a, b) = dfs(nxt)
		sa += a
		sb += b
	return (sa, sb)
for i in range(n):
	if seen[i]:
		continue
	(sa, sb) = dfs(i)
	if sa != sb:
		print('No')
		return
print('Yes')


import sys
from collections import deque
input = sys.stdin.readline
(N, M) = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
edges = [[] for _ in range(N)]
for _ in range(M):
	(c, d) = map(int, input().split())
	c -= 1
	d -= 1
	edges[c].append(d)
	edges[d].append(c)
q = deque()
visited = set()
for i in range(N):
	if i in visited:
		continue
	q.append(i)
	a_sum = 0
	b_sum = 0
	while q:
		n = q.popleft()
		if n in visited:
			continue
		visited.add(n)
		a_sum += A[n]
		b_sum += B[n]
		for nn in edges[n]:
			q.append(nn)
	if a_sum != b_sum:
		print('No')
		return
print('Yes')


from collections import deque
(n, m) = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
G = [[] for _ in range(n)]
for _ in range(m):
	(c, d) = map(lambda x: int(x) - 1, input().split())
	G[c].append(d)
	G[d].append(c)
seen = [False] * n
que = deque()
for i in range(n):
	if not seen[i]:
		que.append(i)
		(a, b) = (0, 0)
		while que:
			v = que.pop()
			a += A[v]
			b += B[v]
			seen[v] = True
			for nv in G[v]:
				if not seen[nv]:
					que.append(nv)
					seen[nv] = True
		if a != b:
			print('No')
			return
print('Yes')


from typing import List

class DSU:

	def __init__(self, n: int) -> None:
		self._n = n
		self.parent_or_size = [-1] * n

	def merge(self, a: int, b: int) -> int:
		assert 0 <= a < self._n
		assert 0 <= b < self._n
		(x, y) = (self.leader(a), self.leader(b))
		if x == y:
			return x
		if -self.parent_or_size[x] < -self.parent_or_size[y]:
			(x, y) = (y, x)
		self.parent_or_size[x] += self.parent_or_size[y]
		self.parent_or_size[y] = x
		return x

	def same(self, a: int, b: int) -> bool:
		assert 0 <= a < self._n
		assert 0 <= b < self._n
		return self.leader(a) == self.leader(b)

	def leader(self, a: int) -> int:
		assert 0 <= a < self._n
		stack = []
		while self.parent_or_size[a] >= 0:
			stack.append(a)
			a = self.parent_or_size[a]
		for i in stack:
			self.parent_or_size[i] = a
		return a

	def size(self, a: int) -> int:
		assert 0 <= a < self._n
		return -self.parent_or_size[self.leader(a)]

	def groups(self) -> List[List[int]]:
		leader_buf = [self.leader(i) for i in range(self._n)]
		group_size = [0] * self._n
		for i in leader_buf:
			group_size[i] += 1
		result = [[] for _ in range(self._n)]
		for i in range(self._n):
			result[leader_buf[i]].append(i)
		result = [i for i in result if i]
		return result
(n, m) = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
uf = DSU(n)
for i in range(m):
	(x, y) = list(map(int, input().split()))
	uf.merge(x - 1, y - 1)
for u in uf.groups():
	diff = 0
	for aa in u:
		diff += a[aa] - b[aa]
	if diff != 0:
		print('No')
		return
print('Yes')


class UnionFind:

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

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

	def union(self, x, y):
		x = self.find(x)
		y = self.find(y)
		if x == y:
			return
		if self.parents[x] > self.parents[y]:
			(x, y) = (y, x)
		self.parents[x] += self.parents[y]
		self.parents[y] = x

	def __str__(self):
		return '\n'.join(('{}: {}'.format(r, self.members(r)) for r in self.roots()))

def main():
	(N, M) = list(map(int, input().split()))
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	if sum(A) != sum(B):
		print('No')
	else:
		f = 0
		uf = UnionFind(N)
		for _ in range(M):
			(C, D) = list(map(int, input().split()))
			C -= 1
			D -= 1
			uf.union(C, D)
		wa = [0 for i in range(N)]
		tle = [0 for i in range(N)]
		for i in range(N):
			wa[uf.find(i)] += A[i]
			tle[uf.find(i)] += B[i]
		if wa == tle:
			print('Yes')
		else:
			print('No')
main()


class UnionFind:

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

	def _root(self, x):
		stack = []
		tbl = self.table
		while tbl[x] >= 0:
			stack.append(x)
			x = tbl[x]
		for y in stack:
			tbl[y] = x
		return x

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

	def union(self, x, y):
		r1 = self._root(x)
		r2 = self._root(y)
		if r1 == r2:
			return
		d1 = self.table[r1]
		d2 = self.table[r2]
		if d1 <= d2:
			self.table[r2] = r1
			if d1 == d2:
				self.table[r1] -= 1
		else:
			self.table[r1] = r2
(n, m) = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
G = UnionFind(n)
CD = []
for _ in range(m):
	(c, d) = list(map(int, input().split()))
	G.union(c - 1, d - 1)
ansA = [0] * n
ansB = [0] * n
for i in range(n):
	ansA[G._root(i)] += A[i]
	ansB[G._root(i)] += B[i]
if ansA == ansB:
	print('Yes')
else:
	print('No')


from collections import defaultdict

class UnionFind:

	def __init__(self, n):
		self.root = [i for i in range(n + 1)]
		self.size = [1] * (n + 1)

	def find(self, x):
		y = self.root[x]
		if x == y:
			return x
		else:
			z = self.find(y)
			self.root[x] = z
			return z

	def union(self, x, y):
		rx = self.find(x)
		ry = self.find(y)
		sx = self.size[rx]
		sy = self.size[ry]
		if rx == ry:
			return 0
		elif sx >= sy:
			self.root[ry] = rx
			self.size[rx] = sx + sy
		else:
			self.root[rx] = ry
			self.size[ry] = sx + sy
		return sx * sy

	def check(self):
		print([self.find(i) for i in range(1, len(self.root))])
(N, M) = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
CD = [list(map(int, input().split())) for _ in range(M)]
uf = UnionFind(N)
for (c, d) in CD:
	uf.union(c, d)
cnta = defaultdict(int)
cntb = defaultdict(int)
lst = []
for i in range(1, N + 1):
	cnta[uf.find(i)] += A[i - 1]
	cntb[uf.find(i)] += B[i - 1]
	lst.append(uf.find(i))
for l in lst:
	if cnta[l] != cntb[l]:
		print('No')
		return
print('Yes')


import numpy as np
from collections import defaultdict

class UnionFind(object):

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

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

	def unite(self, x, y):
		x = self.find(x)
		y = self.find(y)
		if x == y:
			return False
		if self.root[x] > self.root[y]:
			(x, y) = (y, x)
		self.root[x] += self.root[y]
		self.root[y] = x
		return True

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

	def size(self, x):
		return self.root[self.find(x)] * -1

	def get_all_groups(self):
		all_groups = defaultdict(list)
		for i in range(self.n):
			all_groups[self.find(i)].append(i)
		return dict(all_groups)
(n, m) = map(int, input().split())
a = np.array(list(map(int, input().split())))
b = np.array(list(map(int, input().split())))
uf = UnionFind(n)
for _ in range(m):
	(c, d) = map(int, input().split())
	uf.unite(c - 1, d - 1)
for i in uf.get_all_groups().values():
	if a[i].sum() != b[i].sum():
		print('No')
		return
print('Yes')


class UnionFind:

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

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

	def union(self, x, y):
		x = self.find(x)
		y = self.find(y)
		if x == y:
			return
		if self.parents[x] > self.parents[y]:
			(x, y) = (y, x)
		self.parents[x] += self.parents[y]
		self.parents[y] = x

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

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

	def members(self, x):
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i) == root]

	def roots(self):
		return [i for (i, x) in enumerate(self.parents) if x < 0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()}

	def __str__(self):
		return '\n'.join(('{}: {}'.format(r, self.members(r)) for r in self.roots()))
(n, m) = map(int, input().split())
uf = UnionFind(n)
a = list(map(int, input().split()))
b = list(map(int, input().split()))
for i in range(m):
	(c, d) = map(int, input().split())
	c -= 1
	d -= 1
	uf.union(c, d)
weights_a = [0] * n
weights_b = [0] * n
for i in range(n):
	weights_a[uf.find(i)] += a[i]
	weights_b[uf.find(i)] += b[i]
for i in range(n):
	if weights_a[i] != weights_b[i]:
		print('No')
		return
print('Yes')


import sys
input = lambda : sys.stdin.readline().rstrip()

class UnionFind:

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

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

	def union(self, x, y):
		x = self.find(x)
		y = self.find(y)
		if x == y:
			return
		if self.parents[x] > self.parents[y]:
			(x, y) = (y, x)
		self.parents[x] += self.parents[y]
		self.parents[y] = x

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

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

	def members(self, x):
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i) == root]

	def roots(self):
		return [i for (i, x) in enumerate(self.parents) if x < 0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()}

	def __str__(self):
		return '\n'.join(('{}: {}'.format(r, self.members(r)) for r in self.roots()))
(n, m) = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
u = UnionFind(n)
for i in range(m):
	(c, d) = list(map(int, input().split()))
	c -= 1
	d -= 1
	u.union(c, d)
a_pa = [0 for i in range(n)]
b_pa = [0 for i in range(n)]
for i in range(n):
	a_pa[u.find(i)] += a[i]
	b_pa[u.find(i)] += b[i]
if a_pa == b_pa:
	print('Yes')
else:
	print('No')


from collections import defaultdict

class UnionFind:

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

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

	def union(self, x, y):
		x = self.find(x)
		y = self.find(y)
		if x == y:
			return
		if self.parents[x] > self.parents[y]:
			(x, y) = (y, x)
		self.parents[x] += self.parents[y]
		self.parents[y] = x

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

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

	def members(self, x):
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i) == root]

	def roots(self):
		return [i for (i, x) in enumerate(self.parents) if x < 0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		group_members = defaultdict(list)
		for member in range(self.n):
			group_members[self.find(member)].append(member)
		return group_members

	def __str__(self):
		return '\n'.join(('{}: {}'.format(r, self.members(r)) for r in self.roots()))
(N, M) = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
uf = UnionFind(N)
for _ in range(M):
	(a, b) = map(int, input().split())
	uf.union(a - 1, b - 1)
members = uf.all_group_members().values()
for r in members:
	sm = 0
	sm_ = 0
	for m in r:
		sm += A[m]
		sm_ += B[m]
	if sm != sm_:
		print('No')
		return
print('Yes')


def init(n):
	nonlocal par
	nonlocal size
	par = [-1] * n
	size = [1] * n

def unite(x, y):
	x -= 1
	y -= 1
	x = get_root(x)
	y = get_root(y)
	if x != y:
		if size[x] < size[y]:
			(x, y) = (y, x)
		par[y] = x
		size[x] += size[y]

def get_root(x):
	if par[x] == -1:
		return x
	else:
		par[x] = get_root(par[x])
		return get_root(par[x])

def is_same(x, y):
	if get_root(x) == get_root(y):
		return True

def get_size(x):
	return size[get_root(x)]
(N, M) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
par = []
size = []
init(N)
for _ in range(M):
	(c, d) = map(int, input().split())
	unite(c, d)
groups = dict()
for i in range(N):
	r = get_root(i)
	if not r in groups.keys():
		groups[r] = [i]
	else:
		groups[r].append(i)
for vertexes in groups.values():
	a_sum = 0
	b_sum = 0
	for v in vertexes:
		a_sum += a[v]
		b_sum += b[v]
	if a_sum != b_sum:
		print('No')
		return
print('Yes')


class UnionFind:

	def __init__(self, n):
		self.n = n
		self.parent = [i for i in range(n)]
		self.rank = [1] * n
		self.size = [1] * n

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

	def unite(self, x, y):
		x = self.find(x)
		y = self.find(y)
		if x != y:
			if self.rank[x] < self.rank[y]:
				self.parent[x] = y
				self.size[y] += self.size[x]
			else:
				self.parent[y] = x
				self.size[x] += self.size[y]
				if self.rank[x] == self.rank[y]:
					self.rank[x] += 1

	def group_members(self, x):
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i) == root]

	def roots(self):
		return [i for (i, x) in enumerate(self.parent) if i == x]

	def all_group_members(self):
		return {r: self.group_members(r) for r in self.roots()}

	def __str__(self):
		return '\n'.join(('{}: {}'.format(r, self.group_members(r)) for r in self.roots()))
(n, m) = list(map(int, input().split()))
uf = UnionFind(n)
al = list(map(int, input().split()))
bl = list(map(int, input().split()))
for _ in range(m):
	(c, d) = [int(x) - 1 for x in input().split()]
	uf.unite(c, d)
asum = [0] * n
bsum = [0] * n
for i in range(n):
	root = uf.find(i)
	asum[root] += al[i]
	bsum[root] += bl[i]
if asum == bsum:
	print('Yes')
else:
	print('No')


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
par = [i for i in range(n + 1)]

def find(x):
	if par[x] == x:
		return x
	else:
		par[x] = find(par[x])
		return par[x]

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

def unite(x, y):
	x = find(x)
	y = find(y)
	if x == y:
		return 0
	par[x] = y
for i in range(m):
	(s, t) = map(int, input().split())
	unite(s, t)
for i in range(n + 1):
	par[i] = find(i)
data = [0 for _ in range(n + 1)]
for i in range(1, n + 1):
	data[par[i]] += a[i - 1]
	data[par[i]] -= b[i - 1]
if data.count(0) == n + 1:
	print('Yes')
else:
	print('No')


I = [int(_) for _ in open(0).read().split()]
(N, M) = I[:2]
A = I[2:2 + N]
B = I[2 + N:2 + N + N]
CD = I[2 + N + N:]
(C, D) = [CD[_::len('CD')] for _ in range(len('CD'))]

class UnionFind:

	def __init__(self, n):
		self.n = n
		self.root = [-1] * (n + 1)
		self.rank = [0] * (n + 1)

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

	def unite(self, x, y):
		x = self.find(x)
		y = self.find(y)
		if x == y:
			return 0
		elif self.rank[x] > self.rank[y]:
			self.root[x] += self.root[y]
			self.root[y] = x
		else:
			self.root[y] += self.root[x]
			self.root[x] = y
			if self.rank[x] == self.rank[y]:
				self.rank[y] += 1

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

	def size(self, x):
		return -self.root[self.find(x)]
uf = UnionFind(N)
for (c, d) in zip(C, D):
	uf.unite(c, d)
sums = [0] * (N + 1)
for i in range(1, N + 1):
	sums[uf.find(i)] += B[i - 1] - A[i - 1]
print('Yes' if all((x == 0 for x in sums)) else 'No')


import math
import collections
import bisect
import itertools
import heapq
import os
from collections import defaultdict, deque, Counter
from sys import stdin
readline = stdin.readline
(N, M) = list(map(int, readline().split()))
a = list(map(int, readline().split()))
b = list(map(int, readline().split()))

class UnionFind:

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

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

	def union(self, x, y):
		x = self.find(x)
		y = self.find(y)
		if x == y:
			return
		if self.parents[x] > self.parents[y]:
			(x, y) = (y, x)
		self.parents[x] += self.parents[y]
		self.parents[y] = x

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

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

	def members(self, x):
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i) == root]

	def roots(self):
		return [i for (i, x) in enumerate(self.parents) if x < 0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		group_members = defaultdict(list)
		for member in range(self.n):
			group_members[self.find(member)].append(member)
		return group_members

	def __str__(self):
		return '\n'.join((f'{r}: {m}' for (r, m) in list(self.all_group_members().items())))
uf = UnionFind(N)
for _ in [0] * M:
	(c, d) = list(map(int, readline().split()))
	uf.union(c - 1, d - 1)
for grp in list(uf.all_group_members().values()):
	a_values = [a[x] for x in grp]
	b_values = [b[x] for x in grp]
	a_total = sum(a_values)
	b_total = sum(b_values)
	if a_total != b_total:
		print('No')
		return
print('Yes')


import sys
try:
	import os
	f = open('input.txt', 'r')
	sys.stdin = f
except FileNotFoundError:
	None
from math import sqrt, ceil, floor
from collections import deque, Counter, defaultdict
input = lambda : sys.stdin.readline().strip()
sys.setrecursionlimit(11451419)
from decimal import ROUND_HALF_UP, Decimal
from functools import lru_cache
from bisect import bisect_left as bileft, bisect_right as biright, insort
from itertools import combinations as com, permutations as per
from fractions import Fraction as frac
(n, m) = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))

class UnionFind:

	def __init__(self, num):
		self.n = num
		self.parents = [{i} for i in range(self.n)]

	def find(self, x):
		if type(self.parents[x]) == set:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self, x, y):
		xx = self.find(x)
		yy = self.find(y)
		if xx == yy:
			return
		else:
			size_xx = len(self.parents[xx])
			size_yy = len(self.parents[yy])
			if size_xx > size_yy:
				(xx, yy) = (yy, xx)
			for t in self.parents[xx]:
				self.parents[yy].add(t)
			self.parents[xx] = yy

	def size(self, x):
		xx = self.find(x)
		return abs(self.parents[xx])

	def same(self, x, y):
		return 1 if self.find(x) == self.find(y) else 0

	def members(self, x):
		xx = self.find(x)
		return [i for i in range(self.n) if self.find(i) == xx]

	def roots(self):
		return [i for (i, x) in enumerate(self.parents) if x < 0]

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()}

	def state_grouping(self):
		return list(self.all_group_members().values())
uf = UnionFind(n)
for i in range(m):
	(a, b) = list(map(int, input().split()))
	a -= 1
	b -= 1
	uf.union(a, b)
X = []
for l in uf.parents:
	if type(l) == set:
		X.append(l)
for l in X:
	ans = 0
	ann = 0
	for i in l:
		ans += A[i]
		ann += B[i]
	if ans != ann:
		print('No')
		return
else:
	print('Yes')


(N, M) = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
CD = [list(map(int, input().split())) for i in range(M)]

class UnionFind:

	def __init__(self, N):
		self.Parent = [-1] * N

	def unite(self, m, n):
		rm = self.root(m)
		rn = self.root(n)
		if rm == rn:
			return False
		else:
			if self.size(rm) < self.size(rn):
				(rm, rn) = (rn, rm)
			self.Parent[rm] += self.Parent[rn]
			self.Parent[rn] = rm
			return True

	def root(self, n):
		if self.Parent[n] < 0:
			return n
		else:
			self.Parent[n] = self.root(self.Parent[n])
			return self.Parent[n]

	def size(self, n):
		return -self.Parent[self.root(n)]
u = UnionFind(N)
for (c, d) in CD:
	u.unite(c - 1, d - 1)
from collections import defaultdict
d = defaultdict(int)
d2 = defaultdict(int)
for i in range(N):
	d[u.root(i)] += A[i]
	d2[u.root(i)] += B[i]
print(['No', 'Yes'][all((d[k] == d2[k] for k in d))])


import sys
from math import gcd, factorial, ceil, floor, sqrt
from bisect import bisect_left, bisect_right
from copy import deepcopy
from heapq import heapify, heappop, heappush
from itertools import permutations, combinations, product, accumulate
from collections import defaultdict, deque, Counter
from functools import lru_cache
sys.setrecursionlimit(10 ** 8)
ii = lambda : int(input())
mi = lambda : list(map(int, input().split()))
li = lambda : list(map(int, input().split()))
(N, M) = mi()
a = li()
b = li()

class UnionFind:

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

	def _root(self, x):
		stack = []
		tbl = self.table
		while tbl[x] >= 0:
			stack.append(x)
			x = tbl[x]
		for y in stack:
			tbl[y] = x
		return x

	def count(self, x):
		return -self.table[self._root(x)]

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

	def union(self, x, y):
		r1 = self._root(x)
		r2 = self._root(y)
		if r1 == r2:
			return
		d1 = self.table[r1]
		d2 = self.table[r2]
		if d1 <= d2:
			self.table[r2] = r1
			self.table[r1] += d2
		else:
			self.table[r1] = r2
			self.table[r2] += d1
ins = UnionFind(N)
for i in range(M):
	(c, d) = mi()
	ins.union(c - 1, d - 1)
d = defaultdict(set)
for i in range(N):
	r = ins._root(i)
	d[r].add(i)
for (i, x) in list(d.items()):
	(num1, num2) = (0, 0)
	for y in x:
		num1 += a[y]
		num2 += b[y]
	if num1 != num2:
		print('No')
		return
print('Yes')


class UnionFind(object):

	def __init__(self, n=1):
		self.par = [i for i in range(n)]
		self.rank = [0 for _ in range(n)]
		self.size = [1 for _ in range(n)]

	def find(self, x):
		if self.par[x] == x:
			return x
		else:
			self.par[x] = self.find(self.par[x])
			return self.par[x]

	def union(self, x, y):
		x = self.find(x)
		y = self.find(y)
		if x != y:
			if self.rank[x] < self.rank[y]:
				(x, y) = (y, x)
			if self.rank[x] == self.rank[y]:
				self.rank[x] += 1
			self.par[y] = x
			self.size[x] += self.size[y]

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

	def get_size(self, x):
		x = self.find(x)
		return self.size[x]
from collections import defaultdict
(N, M) = map(int, input().split())
uf = UnionFind(N)
A = list(map(int, input().split()))
B = list(map(int, input().split()))
for i in range(M):
	(c, d) = map(int, input().split())
	c -= 1
	d -= 1
	uf.union(c, d)
dic = defaultdict(int)
for i in range(N):
	par = uf.find(i)
	dif = A[i] - B[i]
	dic[par] += dif
for v in dic.values():
	if v != 0:
		print('No')
		return
print('Yes')


class Coloring_Union_Find:

	def __init__(self, N, f):
		self.n = N
		self.parents = [-1] * N
		self.data = [0] * N
		self.rank = [0] * N
		self.f = f

	def find(self, x):
		V = []
		while self.parents[x] >= 0:
			V.append(x)
			x = self.parents[x]
		for v in V:
			self.parents[v] = x
		return x

	def union(self, x, y):
		x = self.find(x)
		y = self.find(y)
		if x == y:
			return
		self.data[x] = self.data[y] = self.f(self.data[x], self.data[y])
		if self.rank[x] > self.rank[y]:
			self.parents[x] += self.parents[y]
			self.parents[y] = x
		else:
			self.parents[y] += self.parents[x]
			self.parents[x] = y
			if self.rank[x] == self.rank[y]:
				self.rank[y] += 1

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

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

	def set(self, x, c):
		self.data[self.find(x)] = c
		return

	def look(self, x):
		return self.data[self.find(x)]

	def members(self, x):
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i) == root]

	def roots(self):
		return [i for (i, x) in enumerate(self.parents) if x < 0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		X = {r: [] for r in self.roots()}
		for k in range(self.n):
			X[self.find(k)].append(k)
		return X

	def color_list(self):
		return [self.look(x) for x in range(self.n)]

	def color_map(self):
		return {x: self.look(x) for x in self.roots()}

	def __str__(self):
		return '\n'.join(('{}: {}'.format(r, self.members(r)) for r in self.roots()))
from operator import add
(N, M) = map(int, input().split())
A = [0] + list(map(int, input().split()))
B = [0] + list(map(int, input().split()))
X = [a - b for (a, b) in zip(A, B)]
U = Coloring_Union_Find(N + 1, add)
U.data = X.copy()
for _ in range(M):
	(c, d) = map(int, input().split())
	U.union(c, d)
if U.color_list() == [0] * (N + 1):
	print('Yes')
else:
	print('No')


import math
import copy
import bisect
from itertools import accumulate
from collections import Counter, defaultdict, deque

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

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

def ceil(U, V):
	return (U + V - 1) // V

def modf1(N, MOD):
	return (N - 1) % MOD + 1

class UnionFind:

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

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

	def union(self, x, y):
		x = self.find(x)
		y = self.find(y)
		if x == y:
			return
		if self.parents[x] > self.parents[y]:
			(x, y) = (y, x)
		self.parents[x] += self.parents[y]
		self.parents[y] = x

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

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

	def members(self, x):
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i) == root]

	def roots(self):
		return [i for (i, x) in enumerate(self.parents) if x < 0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()}

	def __str__(self):
		return '\n'.join(('{}: {}'.format(r, self.members(r)) for r in self.roots()))
(n, m) = mp()
a = lmp()
b = lmp()
uf = UnionFind(n)
ar = copy.deepcopy(a)
br = copy.deepcopy(b)
for i in range(m):
	(c, d) = mp()
	(e, f) = (uf.find(c - 1), uf.find(d - 1))
	uf.union(c - 1, d - 1)
	g = uf.find(c - 1)
	if e == f:
		pass
	elif e == g:
		ar[e] += ar[f]
		br[e] += br[f]
	else:
		ar[f] += ar[e]
		br[f] += br[e]
rot = uf.roots()
for i in rot:
	if ar[i] != br[i]:
		print('No')
		return
print('Yes')


from collections import defaultdict

class UnionFind:

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

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

	def union(self, x, y):
		x = self.find(x)
		y = self.find(y)
		if x == y:
			return
		if self.parents[x] > self.parents[y]:
			(x, y) = (y, x)
		self.parents[x] += self.parents[y]
		self.parents[y] = x

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

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

	def members(self, x):
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i) == root]

	def roots(self):
		return [i for (i, x) in enumerate(self.parents) if x < 0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		group_members = defaultdict(list)
		for member in range(self.n):
			group_members[self.find(member)] = 0
		for member in range(self.n):
			group_members[self.find(member)] += A[member] - B[member]
		return group_members

	def __str__(self):
		return '\n'.join((f'{r}: {m}' for (r, m) in self.all_group_members().items()))
(N, M) = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
L = UnionFind(N)
for i in range(M):
	(c, d) = map(int, input().split())
	c -= 1
	d -= 1
	L.union(c, d)
for i in list(L.all_group_members().items()):
	if i[1] != 0:
		print('No')
		return
print('Yes')


def find(x):
	if par[x] == x:
		return x
	else:
		par[x] = find(par[x])
		return par[x]

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

def unite(x, y):
	x = find(x)
	y = find(y)
	if x == y:
		return 0
	par[x] = y

def groups(par):
	leader_buf = [find(par[i]) for i in range(len(par))]
	result = [[] for _ in range(len(par))]
	for i in range(len(par)):
		result[leader_buf[i]].append(i)
	return [r for r in result if r != []]
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
par = [[] for _ in range(n + 1)]
for i in range(n + 1):
	par[i] = i
for i in range(m):
	(c, d) = map(int, input().split())
	unite(c, d)
g = groups(par)
for i in range(1, len(g)):
	asum = 0
	bsum = 0
	for j in range(len(g[i])):
		asum += a[g[i][j] - 1]
		bsum += b[g[i][j] - 1]
	if asum != bsum:
		print('No')
		return
print('Yes')


class union_find:

	def __init__(self, n):
		self.root = [-1] * (n + 1)
		self.rank = [0] * (n + 1)
		self.siz = n

	def find_root(self, x):
		if self.root[x] < 0:
			return x
		else:
			self.root[x] = self.find_root(self.root[x])
			return self.root[x]

	def unite(self, x, y):
		x = self.find_root(x)
		y = self.find_root(y)
		if x == y:
			return
		elif self.rank[x] > self.rank[y]:
			self.root[x] += self.root[y]
			self.root[y] = x
		else:
			self.root[y] += self.root[x]
			self.root[x] = y
			if self.rank[x] == self.rank[y]:
				self.rank[y] += 1
		self.siz -= 1

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

	def size(self):
		return self.siz
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
if sum(a) != sum(b):
	print('No')
	return
g = union_find(n)
for _ in range(m):
	(c, d) = map(int, input().split())
	c -= 1
	d -= 1
	g.unite(c, d)
aa = [0] * n
bb = [0] * n
for i in range(n):
	j = g.find_root(i)
	aa[j] += a[i]
	bb[j] += b[i]
if aa == bb:
	print('Yes')
else:
	print('No')