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

struct Edge {
    int to;
};
using Graph = vector<vector<Edge>>;

vector<int> V[200010];

// 深さ優先探索
vector<bool> seen;  // 探索したか記録
void dfs2(const Graph &GG, int v,int cnt) {
    //printf("z");
    seen[v] = true;
    for (auto e : GG[v]) {
        if (!seen[e.to]) {  // 訪問済みでなければ探索
            V[cnt].push_back(e.to);
            dfs2(GG, e.to,cnt);
        }
    }
}

int64 start[200010]={0};
int64 goal[200010]={0};

int main() {
    int n, m;
    int flag=1;
    cin >> n >> m;

    for(int i=0;i<n;i++)
    {
        int64 x=0;
        scanf("%lld",&x);
        start[i]=x;
    }

    for(int j=0;j<n;j++)
    {
        int64 y=0;
        scanf("%lld",&y);
        goal[j]=y;
    }

    Graph G(n);
    for (int i = 0; i < m; i++) {
        //printf("a");
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back({b});
        G[b].push_back({a});
    }
    //printf("a");
    seen.assign(n, false);  // 初期化
    int cnt = 0;

    int64 size=0;
    int64 asum=0;
    int64 bsum=0;

    for (int i = 0; i < n; i++) {
        if (!seen[i]) {
            //printf("a");

            V[cnt].push_back(i);

            dfs2(G, i,cnt);

            size = V[cnt].size();
            asum = 0;
            bsum = 0;
            for(int j=0;j<size;j++)
            {
                //printf("%d ",V[cnt][j]);
                asum+=start[V[cnt][j]];
                bsum+=goal[V[cnt][j]];
            }
            //printf("\nasum=%lld\n",asum);
            //printf("bsum=%lld\n",bsum);
            if(asum!=bsum)flag=0;


            cnt++; // dfsした回数をカウント
        }
    }
    //cout << cnt << endl;
    //cout << flag << endl;

    if(flag)printf("Yes");
    else printf("No");

    return 0;
}
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef double dd;
#define tst int tttt;cin>>tttt;for(int TTTT=1;TTTT<=tttt;TTTT++)
#define nl cout<<"\n";
#define forn(a,b) for(int ii=a;ii<b;ii++)
const ll MOD1=1e9+7;
const ll MOD2=998244353;
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define vi vector<int>
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define hhh cout<<"here"<<endl;

ll mod=MOD1;
ll po(ll x,ll y) {y%=mod;ll res=1;while(y>0){if(y&1)res=(res*x);x=(x*x);y>>=1;}return res;}
ll gcd(int a, int b){if(a<b) swap(a,b);if(b==0) return a;return gcd(a%b,b);}

void solve(){
    int n,m;cin>>n>>m;
    vi a(n+1),b(n+1);
    forn(1,n+1)cin>>a[ii];
    forn(1,n+1)cin>>b[ii];
    vector<vi> adj(n+1);
    forn(0,m){
        int u,v;cin>>u>>v;
        adj[u].pb(v);adj[v].pb(u);
    }vector<bool> vis(n+1);
    for(int i=1;i<=n;i++){
        if(!vis[i]){
            vis[i]=true;
            ll p=0,q=0;
            stack<int> st;st.push(i);
            while(!st.empty()){
                int u=st.top();st.pop();
                p+=a[u];q+=b[u];
                for(auto v:adj[u]){
                    if(!vis[v]){
                        vis[v]=true;
                        st.push(v);
                    }
                }
            }if(p!=q){
                cout<<"No";return;
            }
        }
    }cout<<"Yes";
}
int main(){

    // fastio
    // ++*(int*)0;// crash
    // freopen("out.txt","r",stdin);freopen("outt.txt","w",stdout);
    // tst
    {
        solve();nl;
    }
}
/*


*/
