#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define int long long
#define big 998244353
#define ff first
#define se second
#define pb push_back
#define pii pair<int,int>
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define mp make_pair
#define pi 3.141592653589
int power(int x,int y){
    int r=1,z=x;
    while(y){
        if(y & 1)r*=z;
        z*=z;y=y>>1;}
    return r;}
int powerm(int x,int y,int p){
    int r=1;
    while(y){
        if(y & 1)r=(r*x)%p;
        y=y>>1;
        x=(x*x)%p;}
    return r%p;}
int modinv(int x,int m){
    return powerm(x,m-2,m);}
int logarithm(int a,int b){
    int x=0;
    while(a>1){
        x++;
        a/=b;}
    return x;}
vector<int> ad[200005];
int vis[200005];
vector<int> gr;
void dfs(int x){
	vis[x]=1;
	gr.pb(x);
	for(auto p:ad[x])
		if(!vis[p])
			dfs(p);
}
int32_t main(){
    fast;
    int n,m;
    cin>>n>>m;
    vector<int> a(n),b(n);
    for(int i=0;i<n;i++)
    	cin>>a[i];
    for(int i=0;i<n;i++)
    	cin>>b[i];
    for(int i=1;i<=m;i++){
    	int u,v;
    	cin>>u>>v;
    	ad[u].pb(v);
    	ad[v].pb(u);
    }
    for(int i=1;i<=n;i++){
    	gr.clear();
    	if(!vis[i])
    		dfs(i);
    	int sum1,sum2;
    	sum1=sum2=0;
    	for(auto p:gr){
    		sum2+=b[p-1];
    		sum1+=a[p-1];
    	}
    	if(sum1!=sum2){
    		cout<<"No";
    		return 0;
    	}
    }
    cout<<"Yes";
    return 0;
}
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<int,int>
#define                           node(a,b,c)                 mp(mp(a,b),c)
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=200005;
int a[M],b[M],par[M],asum[M],bsum[M],sz[M],ok[M];
int fnd(int x)
{
    if(par[x]==x)return x;
    return par[x]=fnd(par[x]);
}
void tie(int x,int y)
{
    int fx=fnd(x);
    int fy=fnd(y);
    if(fx==fy)return ;
    par[fx]=fy;
}
 main()

{
    fast
    int n,m;
    cin>>n>>m;
    f(i,1,n)cin>>a[i],par[i]=i;
    f(i,1,n)cin>>b[i];
    f(i,1,m)
    {
        int u,v;
        cin>>u>>v;
        tie(u,v);
    }
    f(i,1,n)
    {
        int p=fnd(i);
        asum[p]+=a[i];
        bsum[p]+=b[i];
    }
    f(i,1,n)
    {
        if(asum[i]!=bsum[i])
        {
            cout<<"No\n";return 0;
        }
    }
    cout<<"Yes\n";
    return 0;

}



































