#include<bits/stdc++.h>
#define ll          long long
#define ld          long double
#define mod         998244353
#define INF         998244353
#define ull         unsigned long long
#define pb          push_back
#define	endl		'\n'
#define pi          acos(-1)
#define pii         pair<ll int,ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define SIZE(X)     ((int)((X).size()))
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define fo(i,s,n)  for(int i=s;i<n;i++)
#define FORE(i,s,n) for(int i=s;i<=n;i++)
#define rep(i,n) for(int i=0;i<(n);++i)
#define repf(i,a,b) for(int i=(a);i<=(b);++i)
#define ERASE(x)    x.erase(unique(x.begin(),x.end()),x.end()) //removes repeated element;
#define Fast        ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);

using namespace std;
const int N = 2*100010;
vector <ll> is_prime(N+1 , true);
bool sortinrev(const pair<int,int> &a,const pair<int,int> &b){return (a.first > b.first);}
bool sortbysecdesc(const pair<int,int> &a,const pair<int,int> &b){return a.second>b.second;}
bool sortbysec(const pair<int,int> &a,const pair<int,int> &b) {return (a.second < b.second);}
ll powerm(ll a, ll k) { if (!k) {return 1;}ll b = powerm(a, k / 2);b = b * b % INF;if (k % 2) {return a * b % INF;} else {return b;}}
ll int power(ll int a , ll int b) { if(b == 1) return a; if(b == 0) return 1; ll int m1 = power(a,b/2); if(b%2) return m1*m1*a; return m1*m1; }
void seive_of_eras(ll n) { is_prime[0] = 0; is_prime[1] = 0; for(ll i=2;i*i<=n;i++) { if(is_prime[i]) { for(ll j=i*i;j<=n;j+=i) { is_prime[j] = false; } } } }
bool isprime (ll a) { if(a<=1) return false; if(a==2||a==3) return true; if(a%2==0||a%3==0) return false; for(ll i=5;i*i<=a;i=i+6) { if(a%i==0||a%(i+2)==0) return false; } return true;}

vector <ll> adj[N];
ll visited[N];
ll a[N] , b[N];
ll d = 0;

void dfs(ll u)
{
    //ll d = 0;
    for(ll i=0;i<adj[u].size();i++)
    {

        if(visited[adj[u][i]]==0)
        {
            d += b[adj[u][i]]-a[adj[u][i]];
            //cout<<" "<<adj[u][i]<<" "<<b[adj[u][i]]<<" "<<a[adj[u][i]]<<" "<<d<<endl;
            visited[adj[u][i]] = 1;
            dfs(adj[u][i]);
        }
    }
}

void codeit()
{
    ll n , m; cin>>n>>m;
    for(ll i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    for(ll i=1;i<=n;i++)
    {
        cin>>b[i];

    }
    for(ll i=0;i<m;i++)
    {
        ll c , d; cin>>c>>d;
        adj[c].pb(d);
        adj[d].pb(c);
    }
    for(ll i=1;i<=n;i++)
    {
        if(visited[i]==0)
        {
            visited[i] = 1;
            d = b[i]-a[i];
            dfs(i);
            if(d==0)
            {

            }
            else
            {
                cout<<"No"<<endl;
                //cout<<i<<" "<<d<<endl;
                return;
            }
        }
    }
    cout<<"Yes"<<endl;
    return;
}

int main()
{
    //Fast
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ll tt; tt = 1;
    //cin>>tt;
    for(ll i=0;i<tt;i++)
        codeit();
}


// dont stop until you reach there 
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long 
#define rep(i,j,k) for(int i=j;i<k;i+=1)
#define rrep(i,j,k) for(int i=n-1;i>=0;i-=1)
#define sorti(v) sort(v.begin(),v.end())
#define sortd(v) sort(v.begin(),v.end(),greater<int>())
#define mm map<int,int>
#define vv vector<int>
#define tmm map<int,map<int,int>>
#define trav(a, x) for(auto& a : x)
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define all(v) v.begin(),v.end()
#define pb push_back
#define alot(x,y) memset(x,y,sizeof(x))
#define pii pair<int,int>
#define code ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
const int MOD=1e9+7;
const double pi=acos(-1.0);
//memset(array_name,value_to_be_intialized,sizeof(array_name));
// __builtin_popcount(n) count no of set bit in number n
//next_permutation(s.begin(),s.end());
/*int change(string g){
     int p=10;
     int ans=g[g.length()-1]-'0';
     for(int i=g.length()-2;i>=0;i--){
         int j=g[i]-'0';
         ans=p*ans+j;
     }
     return ans;
}
int binpow(int a,int b){
    int res=1;
    while(b>0){
        if(b&1)res*=a;
        a*=a;
        b>>=1;
        
    }
    return res;
}
// lower_bound==> if the element is present it return its first occurence else 1st element which is greater than 
// upper_bound==> it will always return iterator to element which is greater than searched element
*/
int32_t main ()
{
     code;
    int tt;
    //cin>>tt;
    tt=1;
    while(tt--){
        int n,m;
        cin>>n>>m;
        vv a;
        vv b;
        rep(i,0,n){
            int p;
            cin>>p;
            a.pb(p);
            
        }
        rep(i,0,n){
            int p;
            cin>>p;
            b.pb(p);
        }
        int sum1=0,sum2=0;
        set<int>st;
        rep(i,0,m){
            int p,q;
            cin>>p>>q;
            p--;
            q--;
            st.insert(p);
            st.insert(q);
        }
        trav(x,st){
            sum1+=a[x];
            sum2+=b[x];
        }
        if(m==0){
            if(a==b)cout<<"Yes\n";
            else cout<<"No\n";
        }
        else if(sum1==sum2)cout<<"Yes\n";
        else cout<<"No\n";

    }
    return 0;
    
}
