#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int inf = 1001001001;
ll INF = 1001001001001001001;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define rep(i, n) FOR(i, 0, n)
#define all(x) x.begin(), x.end()
#define pb push_back
#define pf push_front
ll MOD = 1000000007;
using P = pair<ll, ll>;

struct UnionFind{
    vector<int> par;
   
    UnionFind(int N):par(N) {
        for (int i = 0; i < N; i++) par[i] = i;
    }

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

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;
        par[x] = y;
        
    }

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

};


int main() {
    ll N, M;cin >> N >> M;
    vector<ll> A(N), B(N);
    UnionFind tree(N);
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> B[i];
    rep(i, M) {
        int c, d;cin >> c >> d;
        c--;d--;
        tree.unite(c, d);

    }
    ll count[N];
    rep(i, N) count[i] = 0;
    rep(i, N) {
        count[tree.find(i)] += B[i]-A[i];
        
    }
    bool can = true;
    rep(i, N) {
        if (count[i]!=0) {
            can = false;
            break;
        }
    }
    if (can) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

    


#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=200005;
int n,m,k,a[N],b[N],c[N],sa[N],sb[N];
vector<int>e[N];
void dfs(int u)
{
	sa[c[u]]+=a[u];
	sb[c[u]]+=b[u];
	for(auto v:e[u])
	{
		if(!c[v])
		{
			c[v]=c[u];
			dfs(v);
		}
	}
}
signed main()
{
	ios::sync_with_stdio(false);
	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;
		e[u].push_back(v);
		e[v].push_back(u);
	}
	for(int i=1;i<=n;i++)
	{
		if(!c[i])
		{
			k++;
			c[i]=k;
			dfs(i);
			if(sa[k]!=sb[k])
			{
				cout<<"No"<<endl;
				return 0;
			}
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}