#include<bits/stdc++.h>

using namespace std;

const int N=2e5+5;
int a[N],b[N];
bool visited[N];
vector<int>adj[N];
long long add,sub;

void DFS(int cur)
{
    if(visited[cur])return;
    visited[cur]=1;
    if(a[cur] > b[cur])sub+=a[cur]-b[cur];
    else add+=b[cur]-a[cur];
    for(int it : adj[cur])DFS(it);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    int i,m,n,x,y;
    cin >> n >> m;
    for(i=1;i<=n;i++)cin >> a[i];
    for(i=1;i<=n;i++)cin >> b[i];
    while(m--)
    {
        cin >> x >> y;
        adj[x].emplace_back(y);
        adj[y].emplace_back(x);
    }
    for(i=1;i<=n;i++)
    {
        if(!visited[i])
        {
            add=sub=0;
            DFS(i);
            if(add != sub)
            {
                cout << "No";
                return 0;
            }
        }
    }
    cout << "Yes";
    return 0;
}

//#undef DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll llinf = (1ll<<61)-1;
const char lf = '\n', splf[] = " \n";
#define sz(a) int(a.size())
#define all(x) begin(x), end(x)
#define TCC template<class C
#define OSO ostream &operator<<(ostream &os, const
#ifdef DEBUG
const int DEBUG_END = 26;
#define DOS cout
#include <debug.h>
#else
#define bug(args...) void()
#define cbug(a, args...)
#endif
#define ASSERT(a, o, b, args...) if (!((a)o(b))) bug(a, b, ##args), assert((a)o(b));
#define fi first
#define se second
#define Pair make_pair

class DSU//{
{
    vector<int> dsupar;
public:
    int cntDSU;
    vector<int> siz;

    void reset(int nd) {
        for (int i = 0; i <= nd; i++) dsupar[i] = i, siz[i] = 1;
        cntDSU = nd;
    }

    DSU(int N, int noOfSets = -1) {
        dsupar.resize(N+5), siz.resize(N+5);
        reset(N+4);
        cntDSU = noOfSets==-1 ? N : noOfSets;
    }

    int find(int x) {
        return dsupar[x]==x ? x : dsupar[x] = find(dsupar[x]);
    }

    void union_(int u, int v) {
        if ((u = find(u))==(v = find(v))) return;
        if (siz[u]<siz[v]) swap(u, v);
        dsupar[v] = u, siz[u] += siz[v], siz[v] = 0;
        cntDSU--;
    }
    
    bool same(int u, int v) { return find(u)==find(v); }
    
    int size(int u) { return siz[find(u)]; }
    
    vector<vector<int>> groups(int mnNode, int mxNode) {
        vector<vector<int>> ret(mxNode+1);
        for (int i = mnNode; i <= mxNode; ++i) {
            ret[find(i)].push_back(i);
        }
        ret.erase(
            remove_if(ret.begin(), ret.end(), [](const vector<int> &v) { return v.empty(); }),
            ret.end());
        return ret;
    }
};//}
#define yes cout << "Yes\n"
#define no cout << "No\n"

const int inf = 1000000007,N=200005;
int TC=1, CN,n,m,a[N],b[N];
ll sa[N],sb[N];

signed main() { cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit); cout.precision(11), cout.setf(ios::fixed);
    //cin >> TC;// inputAll + resetAll -> solution
    auto kase = [&]()->void {
        cin>>n>>m;
        DSU dsu(n);
        for(int i=1;i<=n;++i)cin>>a[i];
        for(int i=1;i<=n;++i)cin>>b[i];
        for(int i=0;i<m;++i){
            int u,v;
            cin>>u>>v;
            dsu.union_(u,v);
        }
        for(int i=1;i<=n;++i){
            int p=dsu.find(i);
            sa[p]+=a[i],sb[p]+=b[i];
        }
        for(int i=1;i<=n;++i){
            if(sa[i]!=sb[i]){no;return;}
        }
        yes;
    };
    while (CN++!=TC) kase();
}
