#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
template <class T>
using Vec2 = vector<vector<T>>;
#define REP(i, m, n) for(ll i = (m); i < (n); ++i)
#define REPN(i, m, n) for(ll i = (m); i <= (n); ++i)
#define REPR(i, m, n) for(ll i = (m)-1; i >= (n); --i)
#define REPNR(i, m, n) for(ll i = (m); i >= (n); --i)
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <class T1, class T2>
bool chmax(T1 &a, const T2 b){if(a < b){a = b; return true;} return false;}
template <class T1, class T2>
bool chmin(T1 &a, const T2 b){if(a > b){a = b; return true;} return false;}
ll pow2(const int n){return (1LL << n);}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    for (const T &i : v) os << i << ' ';
    return os;
}
void co() { cout << '\n'; }
template <class Head, class... Tail>
void co(Head&& head, Tail&&... tail) {
    cout << head << ' ';
    co(forward<Tail>(tail)...);
}
void ce() { cerr << '\n'; }
template <class Head, class... Tail>
void ce(Head&& head, Tail&&... tail) {
    cerr << head << ' ';
    ce(forward<Tail>(tail)...);
}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const int n){cout << fixed << setprecision(n);}
constexpr int INF = 1000000001;
constexpr ll LINF = 1000000000000000001;
constexpr ll MOD = 1000000007;
constexpr ll MOD_N = 998244353;
constexpr ld EPS = 1e-11;
const double PI = acos(-1);

struct union_find {
    vector<int64_t> par;
    vector<int64_t> _size;
    vector<ll> sa, sb;

    union_find(int64_t _n, vector<ll> a, vector<ll> b) {
        par.resize(_n);
        _size.assign(_n, 1);
        for(int64_t i = 0; i < _n; ++i) par[i] = i;
        sa = a, sb = b;
    }

    int64_t root(int64_t x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int64_t x, int64_t y) {
        x = root(x), y = root(y);
        if (x != y) {
            if (_size[x] > _size[y]) swap(x, y);
            par[y] = x;
            _size[x] += _size[y];
            sa[x] += sa[y];
            sb[x] += sb[y];
        }
    }

    int64_t size(int64_t x) {
        return _size[root(x)];
    }

    bool ok(int64_t x) {
        return sa[root(x)] == sb[root(x)];
    }

    bool same(int64_t x, int64_t y) {
        return root(x) == root(y);
    }
};

int main(void) {
    ll n, m;
    cin >> n >> m;
    Vec a(n), b(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    union_find uf(n, a, b);
    rep(i, m) {
        ll c, d;
        cin >> c >> d;
        --c, --d;
        uf.unite(c, d);
    }

    bool flg = true;
    rep(i, n) flg &= uf.ok(i);
    if (flg) puts("Yes");
    else
        puts("No");

    return 0;
}
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<algorithm>
#include<utility>
#include<map>
#include<tuple>
#include<deque>
using namespace std;
const int mod = 1000000007;
const int INF = 1001001001;
const long long LINF = 1001002003004005006;
const double PI = acos(-1);
int dir4row[] = { 1,0,-1,0 };
int dir4col[] = { 0,1,0,-1 };
int dir8row[] = { 1,1,0,-1,-1,-1,0,1 };
int dir8col[] = { 0,1,1,1,0,-1,-1,-1 };

/*-----------------------------------------------*/

vector<long long> a, b;

struct UnionFind {
	vector<int> r;
	vector<long long> sum1, sum2;
	int N;
	UnionFind(int n) {
		r = vector<int>(n, -1);
		N = n;
		sum1 = vector<long long>(n);
		sum2 = vector<long long>(n);
		for (int i = 0; i < n; ++i) {
			sum1[i] = a[i];
			sum2[i] = b[i];
		}
	}
	int root(int x) {
		if (r[x] < 0) {
			return x;
		}
		return r[x] = root(r[x]);
	}
	bool unite(int a, int b) {
		a = root(a);
		b = root(b);
		if (a == b) {
			return false;
		}
		if (r[a] > r[b]) {
			swap(a, b);
		}
		sum1[a] += sum1[b];
		sum1[b] = 0;
		sum2[a] += sum2[b];
		sum2[b] = 0;
		r[a] += r[b];
		r[b] = a;
		return true;
	}
	bool solve() {
		for (int i = 0; i < N; ++i) {
			if (sum1[i] != sum2[i]) {
				return false;
			}
		}
		return true;
	}
};

int main() {
	int n, m; cin >> n >> m;
	a = vector<long long>(n);
	b = vector<long long>(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> b[i];
	}
	UnionFind uf(n);
	for (int i = 0; i < m; i++) {
		int c, d; cin >> c >> d;
		c--;
		d--;
		uf.unite(c, d);
	}
	if (uf.solve()) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}