// writer: w33z8kqrqk8zzzx33
#include <bits/stdc++.h>
using namespace std;

// begin fast read template by CYJian (source: https://www.luogu.com.cn/paste/i11c3ppx)

namespace io {
	const int __SIZE = (1 << 21) + 1;
	char ibuf[__SIZE], *iS, *iT, obuf[__SIZE], *oS = obuf, *oT = oS + __SIZE - 1, __c, qu[55]; int __f, qr, _eof;
	#define Gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	inline void flush () { fwrite (obuf, 1, oS - obuf, stdout), oS = obuf; }
	inline void gc (char &x) { x = Gc(); }
	inline void pc (char x) { *oS ++ = x; if (oS == oT) flush (); }
	inline void pstr (const char *s) { int __len = strlen(s); for (__f = 0; __f < __len; ++__f) pc (s[__f]); }
	inline void gstr (char *s) { for(__c = Gc(); __c < 32 || __c > 126 || __c == ' ';)  __c = Gc();
		for(; __c > 31 && __c < 127 && __c != ' '; ++s, __c = Gc()) *s = __c; *s = 0; }
	template <class I> inline bool gi (I &x) { _eof = 0;
		for (__f = 1, __c = Gc(); (__c < '0' || __c > '9') && !_eof; __c = Gc()) { if (__c == '-') __f = -1; _eof |= __c == EOF; }
		for (x = 0; __c <= '9' && __c >= '0' && !_eof; __c = Gc()) x = x * 10 + (__c & 15), _eof |= __c == EOF; x *= __f; return !_eof; }
	template <class I> inline void print (I x) { if (!x) pc ('0'); if (x < 0) pc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10; while (qr) pc (qu[qr --]); }
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
} using io::pc; using io::gc; using io::pstr; using io::gstr; using io::gi; using io::print;

// end fast read template by CYJian

#define iter(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define log(a) cerr<<"\033[32m[DEBUG] "<<#a<<'='<<(a)<<" @ line "<<__LINE__<<"\033[0m"<<endl
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
using ll=long long;
using pii=pair<int, int>;
//#define int ll
const int MOD = 1000000007;

int bcj[200005];
ll a[200005], b[200005];
ll as[200005], bs[200005];

int g(int i) {
	if(!bcj[i]) return i;
	return bcj[i] = g(bcj[i]);
}

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n, m; gi(n), gi(m);
	rep1(i, n) gi(a[i]);
	rep1(i, n) gi(b[i]);
	rep(i, m) {
		int c, d; gi(c), gi(d);
		if(g(c) != g(d)) bcj[g(c)] = g(d);
	}
	rep1(i, n) as[g(i)] += a[i], bs[g(i)] += b[i];
	rep1(i, n) if(as[i] != bs[i]) { pstr("No"); return 0; }
	pstr("Yes");
}

#include <cstdio>
#include <algorithm>
#include <cstring>
#include <functional>
#include <cmath>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MOD (ll)1000000007

ll u[200001];
ll a[200001], b[200001];
ll ma[200001], mb[200001];
bool vis[200001];

vector<int> graph[200001];

pll go(int node)
{
	if (vis[node])
		return { 0ll,0ll };

	vis[node] = true;
	pll sum = { a[node], b[node] };
	for (int i = 0; i < graph[node].size(); i++)
	{
		pll temp = go(graph[node][i]);
		sum.first += temp.first, sum.second += temp.second;
	}
	return sum;
}

int main(void)
{
	int n, m;
	int c, d;
	scanf("%d %d", &n, &m);
	fill(u + 1, u + 1 + n, -1ll);
	for (int i = 1; i <= n; i++)
	{
		scanf("%lld", &a[i]);
		ma[i] = a[i];
	}
	for (int i = 1; i <= n; i++)
	{
		scanf("%lld", &b[i]);
		mb[i] = b[i];
	}

	for (int i = 1; i <= m; i++)
	{
		scanf("%d %d", &c, &d);
		graph[c].push_back(d);
		graph[d].push_back(c);
	}

	bool ok = true;
	for (int i = 1; i <= n; i++)
	{
		if (vis[i])
			continue;
		pll temp = go(i);
		if (temp.first != temp.second)
			ok = false;
	}

	printf(ok ? "Yes" : "No");

	return 0;
}