#include <iostream>
#include <cstring>
#include <vector>
using namespace std;
int main(void){
	int N, M;
	cin >> N >> M;
	vector<int> node;
	node.reserve(N);
	int input;
	for(int i=0; i<N; ++i){
		cin >> input;
		node.push_back(input);
	}
	for(int i=0; i<N; ++i){
		cin >> input;
		node.at(i)-=input;
	}
	
	long long int sum = 0;
	int c, d;
	for(int i=0; i<M; ++i){
		cin >> c >> d;
		--c, --d;
		if(node.at(c))
			sum+=node.at(c), node.at(c)=0;
		if(node.at(d))
			sum+=node.at(d), node.at(d)=0;
	} 
	
	if(sum!=0){
		cout << "No" << endl;
		return 0;
	}
	for(int i=0; i<N; ++i){
		if(node.at(i)){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <cstring>
#include <string>
#include <bitset>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;

//infの設定
#define INF32 2147483647
#define INF64 9223372036854775807
#define PRIME 1000000007
#define PI 3.141592653589793238
//repマクロ
#define rep(i,m,n) for (int i=(m); (i)<(int)(n); ++(i))
#define rrep(i,m,n) for (int i=(m); (i)>(int)(n); --(i))
//その他
#define eb emplace_back
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<long long,long long> Pl;
//#define int long long


//UnionFind木
struct UnionFind{
    vector<int> par;

    UnionFind(int n):par(n){
        for(int i=0;i<n;i++) par.at(i)=i;
    }

    int root(int x){
        if(par.at(x)==x) return x;
        return par.at(x)=root(par.at(x));
    }

    int merge(int x,int y){
        int rx=root(x);
        int ry=root(y);
        if(rx==ry) return 0;
        par.at(rx)=ry;
        return 1;
    }

    bool isSame(int x,int y){
        int rx=root(x);
        int ry=root(y);
        return rx==ry;
    }
};


int main(){
    int N,M;
    cin>>N>>M;
    vector<int> A(N),B(N);
    rep(i,0,N) cin>>A[i];
    rep(i,0,N) cin>>B[i];

    UnionFind UF(N);

    rep(i,0,M){
        int c,d;cin>>c>>d;
        UF.merge(c-1,d-1);
    }

    map<int,ll> ma;

    rep(i,0,N){
        int key=UF.root(i);
        if(ma.count(key)==0){
            ma.emplace(key,A[i]-B[i]);
        }else{
            ma.at(key)+=A[i]-B[i];
        }
    }

    for(auto k:ma){
        if(k.second!=0){
            cout<<"No"<<endl;
            return 0;
        }
    }

    cout<<"Yes"<<endl;
    return 0;
}

