#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int n, m;
vector<ll> a, b;
vector<vector<int>> g;
vector<bool> check;

ll dfs(int v) {
	check[v] = true;
	ll ret = b[v] - a[v];
	for (auto nv : g[v]) {
		if (check[nv]) continue;
		ret += dfs(nv);
	}
	return ret;
}

int main() {
	cin >> n >> m;
	a.resize(n);
	b.resize(n);
	rep(i, n) cin >> a[i];
	rep(i, n) cin >> b[i];
	g.resize(n);
	rep(i, m) {
		int c, d;
		cin >> c >> d;
		c--, d--;
		g[c].push_back(d);
		g[d].push_back(c);
	}
	check.resize(n);
	bool ok = true;
	for (int i = 0; i < n; i++) {
		if (check[i]) continue;
		if (dfs(i) != 0) ok = false;
	}
	if (ok) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}
#define ll long long
#define mod 1000000007

#include<bits/stdc++.h>

using namespace std;

const int maxn = 200000;
ll n, m;
ll a[maxn], b[maxn];
ll ss, st; // ssはグラフの実際の合計, stはグラフの理想の合計(ss=stなら"Yes")
ll mark[maxn]; // すでに見た点か判断する
vector<int> adj[maxn]; // グラフ

// 深さ優先探索
void dfs(int v) {
    ss += a[v];
    st += b[v];
    mark[v] = 1;
    for (auto u : adj[v]) {
        if (!mark[u]) dfs(u);
    }
}

int main()
{
	// 入力処理
    cin >> n >> m;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= n; i++) cin >> b[i];
    for (int i = 1; i <= m; i++) {
        int u, v;
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    for (int i = 1; i <= n; i++) {
		// 一つの島(隣接ノードの和)ごとに判定する
		// 一つでもss!=stの島があれば"No"
        if (!mark[i]) {
            ss = 0;
            st = 0;
            dfs(i);
            if (ss != st) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}
