#include <bits/stdc++.h>
namespace IO{
    char buf[1000000],*p1,*p2;
    inline char getc(){
        if(p1==p2) p2=(p1=buf)+fread(buf,1,10,stdin);
        return p1==p2?EOF:*(p1++);
    }
    template<typename tp>inline void r(tp &n){
        n=0;char c=getc();int f=1;
        while(!isdigit(c)&&c!='-') c=getc();
        if(c=='-') f=-1,c=getc();
        while( isdigit(c)) n=n*10+c-48,c=getc();
        n*=f;
    }
    template<typename tp>inline void w(tp  n){
        if(n/10) w(n/10);
        putchar(n%10+48);
    }
};
using namespace IO;
const int N=2e5+5,M=2e5+5;
using namespace std;
int n,m,num;
int vis[N],head[N],nt[M<<1],to[M<<1];
long long a[N],b[N],tota,totb;
void Add(int x,int y){
    ++num;nt[num]=head[x];head[x]=num;to[num]=y;
    ++num;nt[num]=head[y];head[y]=num;to[num]=x;
}
void DFS(int p){
    vis[p]=1;tota+=a[p],totb+=b[p];
    for(int i=head[p];i;i=nt[i])
        if(!vis[to[i]]) DFS(to[i]);
}
int main(){

    //freopen("1.in","r",stdin);

    r(n),r(m);
    for(int i=1;i<=n;++i) r(a[i]);
    for(int i=1;i<=n;++i) r(b[i]);
    for(int i=1,x,y;i<=m;++i)
        r(x),r(y),Add(x,y);
    for(int i=1;i<=n;++i){
        if(vis[i]) continue;
        tota=0;totb=0;DFS(i);
        if(tota!=totb)
            puts("No"),exit(0);
    }
    puts("Yes");
    return 0;
}
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

ll sum[200005];

struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) {}
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0)
            return x;
        else
            return par[x] = root(par[x]);
    }

    bool issame(int x, int y) { return root(x) == root(y); }

    bool merge(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);  // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) { return -par[root(x)]; }
};

int main() {
    long long N, M;
    cin >> N >> M;
    vector<ll> A(N), B(N);
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> B[i];
    vector<int> C(M), D(M);
    for (int i = 0; i < M; ++i) {
        cin >> C[i];
        cin >> D[i];
        --C[i], --D[i];
    }

    rep(i, N) sum[i] = 0;

    UnionFind uf(N);
    rep(i, M) { uf.merge(C[i], D[i]); }

    rep(i, N) {
        int root_i = uf.root(i);
        if (root_i < 0)
            sum[i] += B[i] - A[i];
        else
            sum[root_i] += B[i] - A[i];
    }

    rep(i, N) {
        if (sum[i] != 0) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}