/*
  
  Author: Arnab Sinha
	
  ███████╗██╗  ██╗███████╗██████╗         ██╗      ██████╗  ██████╗██╗  ██╗███████╗██████╗  █████╗  █████╗ 
  ██╔════╝██║  ██║██╔════╝██╔══██╗        ██║     ██╔═══██╗██╔════╝██║ ██╔╝██╔════╝██╔══██╗██╔══██╗██╔══██╗
  ███████╗███████║█████╗  ██████╔╝        ██║     ██║   ██║██║     █████╔╝ █████╗  ██║  ██║╚██████║╚██████║
  ╚════ █║██╔══██║██╔══╝  ██╔══██╗        ██║     ██║   ██║██║     ██╔═██╗ ██╔══╝  ██║  ██║ ╚═══██║ ╚═══██║
  ███████║██║  ██║███████╗██║  ██║███████╗███████╗╚██████╔╝╚██████╗██║  ██╗███████╗██████╔╝ █████╔╝ █████╔╝
  ╚══════╝╚═╝  ╚═╝╚══════╝╚═╝  ╚═╝╚══════╝╚══════╝ ╚═════╝  ╚═════╝╚═╝  ╚═╝╚══════╝╚═════╝  ╚════╝  ╚════╝                                                                                                        
*/
 
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define li long long int
#define ld long double
#define all(v) v.begin(),v.end()
#define rev(a) reverse(all(a))
#define sort(a) sort(all(a))
#define pb push_back
#define INF 1e18+10
#define MINF -1e18-10
#define rep(i,a,b) for(li i=a;i<b;i++)
#define vli vector<li>
#define MAXN 1e5+10
const li mod = 1e9+7;
using namespace std;
 
li power(li a, li b) { a%=mod; li ret = 1; while(b){ if(b&1) ret*=a; a*=a;; if(ret>=mod) ret%=mod; if(a>=mod) a%=mod; b>>=1; } return ret; }
 
template <class T> void read(T& x){
	cin>>x;
}
 
template <class T, class... U> void read(T& x, U&... u){
	read(x);
	read(u...);
}
 
template <class A> void read(vector<A>& v){
	for(auto &it:v)
		read(it);
}
 
template <class A> void print(A x){
	cout<<x;
}
 
template <class A> void printl(A x){
	cout<<x<<endl;
}
 
template <class A> void print(vector<A>& v)
{
	for(auto &it:v){
		print(it);
		cout<<' ';
	}
	cout<<endl;
}

vector<li> v[200005];
bool visited[200005];
long int a[200005],b[200005];
li n,m;
li sum1=0, sum2=0;

void dfs(li num) {
	
	// component_nodes.pb(num);
	sum1+=a[num-1];
	sum2+=b[num-1];

	visited[num] = true;
	for(auto it:v[num]) {
		if(visited[it]==true)
			continue;
		dfs(it);
	}
	return;
}

void solve()
{
	cin>>n>>m;

	rep(i,0,200005){
		visited[i] = false;
	}

	rep(i,0,n)cin>>a[i];
	rep(i,0,n)cin>>b[i];

	rep(i,0,m){
		li c,d;
		cin>>c>>d;

		v[c].pb(d);
		v[d].pb(c);
	}

	rep(i,1,n+1){
			
			if(visited[i]==false){
				// cout<<"Yes\n";
				sum1=sum2=0;
				dfs(i);
			}
			if(sum1!=sum2){
				cout<<"No\n";
				return;
			}
	}

	cout<<"Yes\n";
	// dfs(1,0);
}
 
int main()
{
	IOS;
 
 	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif

	solve();
 
	return 0;
}
#include <iostream>
#include <string>
#include <stdio.h>
#include <math.h>
#include <queue>
#include <algorithm>
#include <utility>
#include <vector>
#include <tuple>
#include <numeric>
using namespace std;


int main(int argc, char* argv[]){
int N,M;
cin >> N >> M;
vector<long long> A(N);
vector<long long> B(N);
vector <pair<int,int>> P(M);

long long sum_a = 0;
long long sum_b = 0;
for(int i=0;i<N;i++){
	cin >> A[i];
	sum_a += A[i];
}
for(int i=0;i<N;i++){
	cin >> B[i];
	sum_b += B[i];
}
vector<int> num(N,0);
for(int i=0;i<M;i++){
	int c,d, tmp;
	cin >> c >> d;
	if(c>d){
		tmp = c;
		c = d;
		d = tmp;
	}
	num[c-1]++;
	num[d-1]++;
	P[i] = make_pair(c, d);
}
bool flag = true;
for(int i=0; i<N; i++){
	if(num[i]==0 && A[i]!=B[i]){
		flag = false;
	}
}

if(sum_a != sum_b || flag==false){
	cout << "No" << endl;
}else{
	cout << "Yes" << endl;
}

return 0;




}
