#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

// UnionFind
class UnionFind{
	vector<int> d;
	int m;
	public:
	UnionFind(int n = 0):d(n,-1),m(1){}
	~UnionFind(){}
	int find(int x){
		if(d[x] < 0) return x;
		return d[x] = find(d[x]);
	}
	bool unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return false; // 既にxとyは繋がっている。
		if(d[x] > d[y]) swap(x,y);
		d[x] += d[y];
		d[y] = x;
		m = (m < -d[x] ? -d[x] : m);
		return true;
	}
	bool same(int x, int y) { return find(x) == find(y);}
  	int size(int x) { return -d[find(x)];}
  	int sizeMax() { return m;}
};

int main() {
	int N, M;
	cin >> N >> M;
	vector<ll> a(N,0);
	vector<ll> b(N,0);
	for(int i = 0; i < N; i++){
		cin >> a[i];
	}
	for(int i = 0; i < N; i++){
		cin >> b[i];
	}
	UnionFind U(N);
	for(int i = 0; i < M; i++){
		int c,d;
		cin >> c >> d;
		c--;
		d--;
		U.unite(c,d);
	}
	map<int,ll> P;
	map<int,ll> Q;
	for(int i = 0; i < N; i++){
		int f = U.find(i);
		P[f] += a[i];
		Q[f] += b[i];
	}
	int f = 0;
	for(auto it = P.begin(); it != P.end(); it++){
		if(P[it->first] != Q[it->first]){
			cout << "No" << endl;
			return(0);
		}
	}
	cout << "Yes" << endl;
	return(0);
}

#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, s, n) for (int i = (s); i < (n); ++i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define len(x) (int)(x).size()
#define pb push_back
#define vi vector<int>
#define vl vector<long long>
#define fast  \
  cin.tie(0); \
  ios::sync_with_stdio(false);
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, int>;

struct UnionFind {
  vector<int> rank, par;
  UnionFind() {}
  UnionFind(int n) {
    rank.resize(n, 0);
    par.resize(n, 0);
    for (int i = 0; i < n; i++) {
      makeTree(i);
    }
  }
  void makeTree(int x) {
    par[x] = x;
    rank[x] = 0;
  }
  bool isSame(int x, int y) { return findRoot(x) == findRoot(y); }
  bool unite(int x, int y) {
    x = findRoot(x);
    y = findRoot(y);
    if (x == y) return false;
    if (rank[x] > rank[y]) {
      par[y] = x;
    } else {
      par[x] = y;
      if (rank[x] == rank[y]) {
        rank[y]++;
      }
    }
    return true;
  }
  int findRoot(int x) {
    if (x != par[x]) {
      par[x] = findRoot(par[x]);
    }
    return par[x];
  }
};

int main() {
  int n, m;
  cin >> n >> m;
  vl a(n), b(n);
  rep(i, 0, n) cin >> a[i];
  rep(i, 0, n) cin >> b[i];
  UnionFind s(n);
  rep(i, 0, m) {
    int a, b;
    cin >> a >> b;
    s.unite(a - 1, b - 1);
  }
  map<int, vi> g;
  rep(i, 0, n) g[s.findRoot(i)].pb(i);
  for(auto i:g){
    ll cnt = 0;
    ll cnt2 = 0;
    for(auto j:i.se){
      cnt += a[j];
      cnt2 += b[j];
    }
    if(cnt != cnt2){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}