#pragma GCC optimize("Ofast", "unroll-loops")
#pragma GCC terget("avx2")

#include <bits/stdc++.h>

struct UnionFind{
    std::vector<int> data;
    /* constructor */
    UnionFind() : data(0) {}
    UnionFind(int sz){ data.assign(sz, -1); }
    /* merge the set to which x belongs and the set to which y belongs */
    bool unite(int x, int y){
        x = find(x); y = find(y);
        if (x == y) return false;
        if (data[x] > data[y]) std::swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return true;
    }
    /* find the root of k */
    int find(int k){
        if (data[k] < 0) return k;
        return data[k] = find(data[k]);
    }
    /* calculate the size of the set to which k belongs */
    int size(int k){ return -data[find(k)]; }
};

using edge = std::pair<int, int>;
using graph = std::vector<edge>;

int N, M;
std::vector<int> a, b;
graph g;

void input(void){
    std::cin >> N >> M;
    a.resize(N);
    for (int& ai : a)
        std::cin >> ai;
    b.resize(N);
    for (int& bi : b)
        std::cin >> bi;
    g.resize(M);
    for (edge& e : g){
        std::cin >> e.first >> e.second;
    	--e.first, --e.second;
    }
}

bool solve(void){
    UnionFind uf(N);
    for (edge& e : g)
        (void)uf.unite(e.first, e.second);
    std::vector<long long> connectedSum_a(N, 0LL), connectedSum_b(N, 0LL);
    for (int i = 0; i < N; ++i){
        int idx = uf.find(i);
        connectedSum_a[idx] += a[i];
        connectedSum_b[idx] += b[i];
    }
    return connectedSum_a == connectedSum_b;
}

int main(void){
    input();
    std::cout << (solve() ? "Yes" : "No") << std::endl;
    return 0;
}
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

class union_find {
    private:
        vector<int> par;
        vector<int> ran;
        vector<ll> size;
    public:
        union_find(int n);
        int find(int x);
        void unite(int x, int y);
        bool same(int x, int y);
        ll show_size(int x);
};

union_find::union_find(int n){
    par.resize(n);
    ran.resize(n);
    size.resize(n);
    rep(i,n) par[i] = i;
    rep(i,n) ran[i] = 0;
    rep(i,n) size[i] = 1;
};

int union_find::find(int x) {
    if(par[x] == x) return x;
    else return par[x] = find(par[x]);
};

void union_find::unite(int x, int y) {
    x = find(x);
    y = find(y);
    if(x == y) return;
    ll t = show_size(x)+show_size(y);
    size[x] = size[y] = t;
    if(ran[x] < ran[y]){
        par[x] = y;
        //size[y] += size[x];
    }
    else{
        par[y] = x;
        //size[x] += size[y];
        if(ran[x] == ran[y]) ran[x]++;
    }
};

ll union_find::show_size(int x) {
    if(par[x] == x) return size[x];
    return show_size(par[x] = find(par[x]));
}

bool union_find::same(int x, int y) {
    return (find(x) == find(y));
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	vector<ll> a(n), b(n);
	rep(i,n) cin >> a[i];
	rep(i,n) cin >> b[i];
	union_find uf(n);
	rep(i,m){
		int c, d;
		cin >> c >> d;
		--c; --d;
		uf.unite(c, d);
	}
	vector<ll> sumA(n, 0), sumB(n, 0);
	rep(i,n){
		int p = uf.find(i);
		sumA[p] += a[i];
		sumB[p] += b[i];
	}
	rep(i,n){
		if(sumA[i] != sumB[i]){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}