///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
using namespace std;
#define                          ll                          long long int
ll gcd(int a,int b)
{
    if(b==0)
        return a;
    return gcd(b,a%b);
}

#define                          in(x)                       scanf("%lld",&x)
#define                          in2(x,y)                    scanf("%lld %lld",&x,&y)
#define                          in3(x,y,z)                  scanf("%lld %lld %lld",&x,&y,&z)
#define                          out(x)                      printf("%lld\n",x)
#define                          cy                          printf("YES\n")
#define                          cn                          printf("NO\n")
#define                          inf                         1e18
#define                          neg                         -1e18
#define                          mx                          2111111
#define                          fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define                          fi                          first
#define                          si                          second
#define                          ce                          cout<<endl
#define                          pb                          push_back
#define                          vc(x)                       x.begin(),x.end()
#define                          pb                          push_back
#define                          pi                          pair<ll,ll>
#define                          debug                       printf("ok\n");
#define                          pg                          pair<ll,ll>,vector<pair<ll,ll> >,greater<pair<ll,ll> >
#define                          mod                         1000000007

vector<ll>g[mx];
bool vis[mx];
ll a[mx],b[mx],m,n,s=0,sum=0;

void dfs(ll u){
 queue<ll>q;
 sum+=a[u];
 s+=b[u];


 vis[u]=1;
 q.push(u);
    while(!q.empty()){
        ll v;
        v=q.front();
        q.pop();
        for(auto x: g[v]){
            if(!vis[x]){
                vis[x]=1;
                sum+=a[x];
                s+=b[x];

                q.push(x);

            }
        }


    }


}


int main(){
    //fast
    ll t;

        ll i,j,m,ans=0,n;
        in2(n,m);
        for(i=1;i<=n;i++)in(a[i]);
        for(i=1;i<=n;i++)in(b[i]);
        ll u,v;
        for(i=0;i<m;i++){
                cin>>u>>v;
                g[v].pb(u);
                g[u].pb(v);
        }
        for(i=1;i<=n;i++){


            if(s!=sum){

                cout<<"No"<<endl;return 0;
            }
            s=0;sum=0;
            if(!vis[i]){
                dfs(i);
            }

        }

    cout<<"Yes"<<endl;

 }




/*
	author: parv2809
*/

#include<bits/stdc++.h>
#define int long long int
#define mod 1000000007
#define inf 1e18
#define fo(i,y,n,inc)	for(int i=y;i<n+y;i+=inc)
#define cin(t) int t;cin>>t
#define w(t) while(t--)
#define nl cout<<endl;
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define ft(i) (i&(-1*i))
#define arrIn(arr,size)		for(int i=0;i<size;i++){cin>>arr[i];}
#define arrOut(arr,size,seperater)	for(int i=0;i<size;i++){cout<<arr[i]<<seperater;}
using namespace std;

int max(int a, int b) {
	if (a > b)
		return a;
	return b;
}

int min(int a, int b) {
	if (a < b)
		return a;
	return b;
}

int powmd(int a, int b) {
	if (b == 1)	return a;
	if (b == 0)	return 1;

	int half = powmd(a, b / 2);
	int ans = half * half;
	ans %= mod;
	if (b & 1) {
		ans *= a;
	}
	ans %= mod;
	return ans;
}

void fastIO() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
}

void dfs(vector<vector<int> >& gr, int src, vector<int>& visited, vector<int>& curr_tree) {

	visited[src] = 1;

	for (auto it : gr[src]) {
		if (!visited[it])
			dfs(gr, it, visited, curr_tree);
	}

	curr_tree.pb(src);
	return;

}


int32_t main() {

	fastIO();
	int t = 1;
	w(t) {

		int n, m;
		cin >> n >> m;

		vector<int> a(n), b(n);

		arrIn(a, n);
		arrIn(b, n);

		vector<vector<int> > graph(n);
		int c, d;
		for (int i = 0; i < m; i++) {
			cin >> c >> d;
			c--, d--;
			graph[c].pb(d);
			graph[d].pb(c);
		}

		vector<int> visited(n, 0);
		bool ans = true;
		for (int i = 0; i < n; i++) {
			if (!visited[i]) {
				vector<int> curr_tree;
				dfs(graph, i, visited, curr_tree);
				int sum = 0;
				for (auto it : curr_tree) {
					sum += (a[it] - b[it]);
				}
				if (sum != 0) {
					ans = false;
					break;
				}
			}
		}
		if (ans)
			cout << "Yes\n";
		else
			cout << "No\n";

	}

	return 0;
}

// cout << "Case #" << i << ": " << answer << endl;