#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>
#include<tuple>
#include<time.h>
#include<list>

#define DIV 1000000007
using namespace std;
using ll = long long;
using ldb = long double;

vector<int> par;
int root(int a) {
	if (par[a] == a)return a;
	else return par[a] = root(par[a]);
}

void unite(int a, int b) {
	int art = root(a), brt = root(b);
	if (art == brt) return;
	par[brt] = art;
}

int main() {
	int N, M; cin >> N >> M;
	par = vector<int>(N + 1);
	vector<ll> p(N + 1), q(N + 1);
	for (int i = 1; i <= N; i++) {
		cin >> p[i];
		par[i] = i;
	}

	for (int i = 1; i <= N; i++) {
		cin >> q[i];
	}

	for (int i = 0; i < M; i++) {
		int c, d; cin >> c >> d;
		unite(c, d);
	}

	vector<ll> rtp(N + 1), rtq(N + 1);
	for (int i = 1; i <= N; i++) {
		int rt = root(i);
		//cout << "i=" << i << " rt=" << rt << endl;
		rtp[rt] += p[i], rtq[rt] += q[i];
	}
	bool fl = true;

	for (int i = 1; i <= N; i++) {
		//cout << rtp[i] << " " << rtq[i] << endl;
		if (rtp[i] != rtq[i]) {
			fl = false;
			break;
		}
	}

	if (fl) cout << "Yes" << endl;
	else cout << "No" << endl;
}
#include <bits/stdc++.h>

#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define FILL0(x) memset(x,0,sizeof(x))
#define FILL1(x) memset(x,-1,sizeof(x))

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
 



vector<ll> G[200000];

bool visited[200000];

vector<vector<ll>> group;

void dfs(int c, ll *ab){
    
    visited[c] = true;
    group[group.size()-1].push_back(c);

    rep(i, G[c].size()){
        if(!visited[G[c][i]])    dfs(G[c][i], ab);
    }
    return; 
}


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    int n, m;
    cin >> n >> m;

    ll a[n], b[n];
    rep(i, n){
        cin >> a[i];
    }
    rep(i, n){
        cin >> b[i];
    }   
    rep(i, m){
        int c, d;
        cin >> c >> d;
        c--; d--;

        G[c].push_back(d);
        G[d].push_back(c);

    }

    ll ab[n];
    rep(i, n){
        ab[i] = a[i]-b[i];
    }

    rep(i, n){
        if(!visited[i]){
            vector<ll> gg;
            group.push_back(gg);
            dfs(i, ab);
        }
    }

    rep(i, group.size()){
        ll tmp = 0;
        rep(j, group[i].size()){
            tmp += ab[group[i][j]];            
        }
        if(tmp != 0){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;





    return 0;

}
