#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define ll long long
#define rep(i,n) for(ll i = 0; i < (n); ++i)
#define REP(i,x,n) for(ll i = (x); i < (n); ++i)
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1);
//const ll mod = 998244353;

template<class T> inline bool chmin(T& a, T b){ if(a > b) { a = b; return true;} return false; }
template<class T> inline bool chmax(T& a, T b){ if(a < b) { a = b; return true;} return false; }
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }

vector<ll> fa;
ll find(ll x){
    return fa[x] == x ? x : fa[x] = find(fa[x]);
}

int main(void)
{
    ll n, m;
    cin >> n >> m;
    vector<ll> a(n), b(n);
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    fa = vector<ll>(n);
    rep(i,n) fa[i] = i;
    rep(i,m){
        ll c, d;
        cin >> c >> d;
        c--; d--;
        c = find(c);
        d = find(d);
        if(c != d) fa[c] = d;
    }
    vector<ll> l(n), r(n);
    rep(i,n){
        l[find(i)] += a[i];
        r[find(i)] += b[i];
    }
    rep(i,n){
        if(l[i] != r[i]){
            puts("No");
            return 0;
        }
    }
    puts("Yes");
    return 0;
}
#include <iostream>
#include <string>
#include <map>
#include<vector>
#include <cmath>
using namespace std;
#define ll long long
vector<int> in;
vector<int> adj[200001];
bool visited[200001];
void dfs(int x) {
    visited[x] = true;
    in.push_back(x);
    for(int next : adj[x]) {
        if(!visited[next]) dfs(next);
    }
}
int main(){
    int n,m;
    cin >> n >> m;
    int v[n], a[n], b[n];
    for(int i=0;i<n;i++) cin >> a[i];
    for(int i=0;i<n;i++) cin >> b[i];
    for(int i=0;i<n;i++) v[i] = a[i]-b[i];
    for(int i=0;i<m;i++) {
        int c,d;
        cin >> c >> d;
        --c, --d;
        adj[c].push_back(d), adj[d].push_back(c);
    }
    bool work = true;
    for(int i=0;i<n && work;i++) {
        if(!visited[i]) {
            in.clear();
            dfs(i);
            ll sum = 0;
            for(auto &it : in) sum+=v[it];
            if(sum!=0) work = false;
        }
    }
    if(!work) cout << "No" << endl;
    else cout << "Yes" << endl;
}

