#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<algorithm>
#include<utility>
#include<map>
#include<tuple>
#include<deque>
using namespace std;
const int mod = 1000000007;
const int INF = 1001001001;
const long long LINF = 1001002003004005006;
const double PI = acos(-1);
int dir4row[] = { 1,0,-1,0 };
int dir4col[] = { 0,1,0,-1 };
int dir8row[] = { 1,1,0,-1,-1,-1,0,1 };
int dir8col[] = { 0,1,1,1,0,-1,-1,-1 };

/*-----------------------------------------------*/

vector<long long> a, b;

struct UnionFind {
	vector<int> r;
	vector<long long> sum1, sum2;
	int N;
	UnionFind(int n) {
		r = vector<int>(n, -1);
		N = n;
		sum1 = vector<long long>(n);
		sum2 = vector<long long>(n);
		for (int i = 0; i < n; ++i) {
			sum1[i] = a[i];
			sum2[i] = b[i];
		}
	}
	int root(int x) {
		if (r[x] < 0) {
			return x;
		}
		return r[x] = root(r[x]);
	}
	bool unite(int a, int b) {
		a = root(a);
		b = root(b);
		if (a == b) {
			return false;
		}
		if (r[a] > r[b]) {
			swap(a, b);
		}
		sum1[a] += sum1[b];
		sum1[b] = 0;
		sum2[a] += sum2[b];
		sum2[b] = 0;
		r[a] += r[b];
		r[b] = a;
		return true;
	}
	bool solve() {
		for (int i = 0; i < N; ++i) {
			if (sum1[i] != sum2[i]) {
				return false;
			}
		}
		return true;
	}
};

int main() {
	int n, m; cin >> n >> m;
	a = vector<long long>(n);
	b = vector<long long>(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> b[i];
	}
	UnionFind uf(n);
	for (int i = 0; i < m; i++) {
		int c, d; cin >> c >> d;
		c--;
		d--;
		uf.unite(c, d);
	}
	if (uf.solve()) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<vs> vvs;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
const ll mod = 1000000007;

int main() {
    int N, M; cin >> N >> M;
    vi As(N);
    rep(i, N) cin >> As[i];
    vi Bs(N);
    rep(i, N) cin >> Bs[i];
    vi Cs(M);
    vi Ds(M);
    vvi adj(N, vi(0));
    rep(i, M) {
        cin >> Cs[i] >> Ds[i];
        Cs[i]--;
        Ds[i]--;
        adj[Cs[i]].push_back(Ds[i]);
        adj[Ds[i]].push_back(Cs[i]);
    }
    // グループの合計値が前後一致していればOK

    vector<bool> seen(N, false);
    int groupCnt = -1;
    vvi G(N, vi(0));
    rep(i, N){
        if(seen[i]) continue;
        seen[i] = true;
        groupCnt++;
        G[groupCnt].push_back(i);
        queue<int> q;
        q.push(i);
        while(!q.empty()){
            int cur = q.front();
            q.pop();
            for(int x: adj[cur]){
                if(seen[x]) continue;
                q.push(x);
                seen[x] = true;
                G[groupCnt].push_back(x);
            }
        }
    }
    string ans = "Yes";
    rep(i, groupCnt + 1){
        ll beforeSum = 0;
        ll afterSum = 0;
        for(int x: G[i]){
            beforeSum += As[x];
            afterSum += Bs[x];
        }
        if(beforeSum != afterSum){
            ans = "No";
            break;
        }
    }
    cout << ans << endl;

    return 0;
}