#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<long long> Vll;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793
 
struct UnionFind{
        vector<int> par;         // par[自分]=親
        UnionFind(ll N) :par(N){
            rep(i,N) par[i]=i;
        }
    int root(int x){ //データxの木の根を得る
        if(par[x] ==x)return x;
        return par[x]=root(par[x]);
    }
    void unite(int x,int y){ // xとyの木を併合
        int rx=root(x);
        int ry=root(y);
        if(rx==ry)return;
        par[rx]=ry;
    }

    bool same(int x,int y){ //x,yの木の根が同じならtrueを返す
        int rx=root(x);
        int ry=root(y);
        return rx==ry;
    }
    
};

int main(){
    ll n,m;
    cin >> n >> m;
    Vll a(n),b(n);
    rep(i,n)cin >>a[i];
    rep(i,n)cin >> b[i];
    UnionFind tree(n);
    rep(i,m){
        ll c,d;
        cin >> c>> d;
        tree.unite(c-1,d-1);
    }
    map<ll,ll > aa,bb;
    rep(i,n){
        if(aa.count(tree.root(i))){
            aa[tree.root(i)]+=a[i];
            bb[tree.root(i)]+=b[i];
        }
        else{
            aa[tree.root(i)]=a[i];
            bb[tree.root(i)]=b[i];
        }
    }
    bool ans=true;
    for(auto p: aa){
        ll x=p.first;
        if(aa[x]==bb[x])continue;
        else {
            ans=false;
            break;
        }
    }
    if(ans)cout << "Yes" << endl;
    else cout << "No" << endl;
    
     
}


#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>
#include <cassert>

using namespace std;
typedef long long ll;

int N, M;
vector<ll> A;
vector<ll> B;
vector<int> edge[200010];
bool arrived[200010];
pair<ll, ll> dfs(int cur)
{
   pair<ll, ll> ret = {A[cur], B[cur]};
   arrived[cur] = true;
   for (int i = 0; i < (int)edge[cur].size(); i++)
   {
      int nxt = edge[cur][i];
      if (arrived[nxt] == false)
      {
         pair<ll, ll> p = dfs(nxt);
         ret.first += p.first;
         ret.second += p.second;
      }
   }
   //cout << cur << " " << ret.first << " " << ret.second << endl;
   return ret;
}

int main()
{
   cin >> N >> M;
   for (int i = 0; i < N; i++)
   {
      int a;
      cin >> a;
      A.emplace_back(a);
   }
   for (int i = 0; i < N; i++)
   {
      int b;
      cin >> b;
      B.emplace_back(b);
   }
   for (int i = 0; i < M; i++)
   {
      int c, d;
      cin >> c >> d;
      c--;
      d--;
      edge[c].emplace_back(d);
      edge[d].emplace_back(c);
   }
   memset(arrived, false, sizeof(arrived));
   for (int i = 0; i < N; i++)
   {
      if (arrived[i] == false)
      {
         pair<ll, ll> p = dfs(i);
         if (p.first != p.second)
         {
            cout << "No" << endl;
            return 0;
         }
      }
   }
   cout << "Yes" << endl;
   return 0;
}
