#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

struct UnionFind {
    vector<int> par, siz;

    UnionFind(int n) : par(n), siz(n, 1) {
        iota(par.begin(), par.end(), 0);
    }

    int root(int x) {
        if (par[x] == x)
            return x;
        else
            return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }

    int size(int x) {
        return siz[root(x)];
    }
};

signed main() {
    int n, m;
    cin >> n >> m;
    ll a[n], b[n];
    rep(i, n) {
        cin >> a[i];
    }
    rep(i, n) {
        cin >> b[i];
    }
    UnionFind uf(n);
    int c, d;
    rep(i, m) {
        cin >> c >> d;
        c--;
        d--;
        uf.unite(c, d);
    }
    map<int, ll> suma, sumb;
    rep(i, n) {
        suma[uf.root(i)] += a[i];
        sumb[uf.root(i)] += b[i];
    }
    for (auto i : suma) {
        if (i.second != sumb[i.first]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
struct Edge {
	int to, nxt;
} E[N << 1];
int n, m, cnt, head[N], a[N], b[N];
long long sum;
bool vis[N];
void addedg(int u, int v) {
	E[++cnt] = (Edge){v, head[u]};
	head[u] = cnt;
}
void dfs(int u) {
	vis[u] = true;
	sum += a[u] - b[u];
	for (int i = head[u]; i; i = E[i].nxt) {
		int v = E[i].to;
		if (vis[v]) continue;
		dfs(v);
	}
}
int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
	for (int i = 1; i <= n; i++) scanf("%d", &b[i]);
	for (int i = 1; i <= m; i++) {
		int u, v;
		scanf("%d%d", &u, &v);
		addedg(u, v);
		addedg(v, u);
	}
	for (int i = 1; i <= n; i++)
	if (!vis[i]) {
		sum = 0;
		dfs(i);
		if (sum) {
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
}