#include <bits/stdc++.h>

using namespace std;
vector<vector<long long>> graf;
vector<long long> val, trz;
vector<bool> odw;
long long curVal, curTrz;

void dfs(long long x){
	odw[x] = true;
	curVal+=val[x];
	curTrz+=trz[x];
	for(auto it:graf[x]){
		if(!odw[it]) dfs(it);
	}
}
	
int main(){
	ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr);
	long long n, m; cin>>n>>m;
	odw.resize(n);
	graf.resize(n);
	
	for(long long i = 0; i < n; i++){
		long long a; cin>>a; val.push_back(a);
	}
	for(long long i = 0; i < n; i++){
		long long a; cin>>a; trz.push_back(a);
	}
	for(long long i = 0; i < m; i++){
		long long a, b; cin>>a>>b;
		a--; b--;
		graf[a].push_back(b);
		graf[b].push_back(a);
	}
	for(long long i = 0; i < n;i++){
		if(!odw[i]){
			curVal=0;
			curTrz=0;
			dfs(i);
			if(curVal!=curTrz) {cout<<"No"; return 0;}
		}
	}
	cout<<"Yes";
			
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+9;
const int MAX=1e2+9;
const double ep=1e-10;
const int mod=1e9+7;
const int INF=0x3f3f3f3f;
const double inf=1e20;
const double pi=acos(-1);
#define debug1 puts("?");
#define debug(x) cout<<"##"<<(x)<<endl;
#define mk make_pair
#define PII pair<int,int>
#define PDI pair<double,int>
#define PIII pair<int,PII >
#define PIII1 pair<PII,int>
#define PIIII pair<PII,PII >
#define PIL pair<int,ll>
#define PLI pair<ll,int>
#define PLIII pair<PLI,PII >
#define PLL pair<ll,ll>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define dep(i,a,b) for(int i=(a);i>=(b);--i)
#define sd(x) scanf("%d",&(x))
#define slld(x) scanf("%lld",&(x))
#define sdd(x,y) scanf("%d%d",&(x),&(y))
#define sc(s) scanf("%s",(s))
#define pd(x) printf("%d\n",(x))
#define plld(x) printf("%lld\n",(x))
#define pdk(x) printf("%d ",(x))
#define plldk(x) printf("%lld ",(x))
#define pdd(x,y) printf("%d %d\n",(x),(y))
#define PR(x) printf("Case %d: ",(x))

/*
*/
int n,m,pre[maxn];
int Find(int x)
{
	return pre[x]==x?x:pre[x]=Find(pre[x]);
}
void mix(int x,int y)
{
	int fx=Find(x),fy=Find(y);
	pre[fx]=fy;
}
ll a[maxn],b[maxn],sum1[maxn],sum2[maxn];
bool vis[maxn];
void solve()
{
	sdd(n,m);
	rep(i,1,n)pre[i]=i;
	rep(i,1,n)slld(a[i]);
	rep(i,1,n)slld(b[i]);
	rep(i,1,m)
	{
		int u,v;
		sdd(u,v);
		mix(u,v);
	}
	rep(i,1,n)
	{
		int fx=Find(i);
		vis[fx]=1;
		sum1[fx]+=a[i];
		sum2[fx]+=b[i];
	}
	rep(i,1,n)
	{
		if(vis[i]&&sum1[i]!=sum2[i])
		{
			puts("No");return;
		}
	}
	puts("Yes");
}
int main()
{
//    ios::sync_with_stdio(false);
//    cin.tie(0);
    int T=1;
//    sd(T);
    while(T--)solve(); 
}