#include<bits/stdc++.h>
using namespace std;
#define int long long
const int maxn = 2e5 + 5;
vector<int> adj[maxn];
int x, y;
int a[maxn], b[maxn];
bool visited[maxn];

void dfs(int src)
{
	visited[src] = true;
	x += a[src];
	y += b[src];
	for (auto node : adj[src])
	{
		if (!visited[node])
		{
			dfs(node);
		}
	}
}

int32_t main()
{
	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	for (int i = 1; i <= n; i++)
		cin >> b[i];
	for (int i = 0, u, v; i < m; i++)
	{
		cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}

	bool ispossible = true;
	for (int i = 1; i <= n; i++)
	{
		if (!visited[i])
		{
			x = y = 0;
			dfs(i);
			if (x != y)
			{
				ispossible = false;
				break;
			}
		}
	}
	if (ispossible)
		cout << "Yes" << "\n";
	else
		cout << "No" << "\n";
	return 0;
}
#include <bits/stdc++.h>
using namespace std;
   
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
   
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
#define setp(x) fixed << setprecision(x)
#define ordered_set tree<pair<long double, int> , null_type,less<pair<long double, int> >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
   
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
   
const int inf = int(1e9);
const ll INF = ll(1e16);
const int mod = inf + 7;
const double PI = acos(-1.0);
void mul(ll &x, ll y){
  x *= y;
  if(x >= mod) x %= mod;
} 
ll bp(ll a, ll n, ll cm){
  ll r = 1;
  while(n){
    if(n & 1) r = r * a % cm;
    a = a * a % cm;
    n >>= 1;
  }
  return r; 
}
template<typename T_vector> // neal
void output_vector(const T_vector &v, bool add_one = false, int start = -1, int end = -1) {
    if (start < 0) start = 0;
    if (end < 0) end = int(v.size());
  
    for (int i = start; i < end; i++)
        cout << v[i] + (add_one ? 1 : 0) << (i < end - 1 ? ' ' : '\n');
}
const int N = 200200;
int a[N], b[N], used[N];
vector<int> g[N];
vector<int> id, val;
ll s1, s2;
void dfs(int v){
  used[v] = 1;
  s1 += a[v];
  s2 += b[v];
  for(int to : g[v]){
    if(!used[to]){
      dfs(to);
    }
  }
}
void solve(){
  int n, m;
  cin >> n >> m;
  rep(i, n){
    cin >> a[i];
  }
  rep(i, n){
    cin >> b[i];
  }
  rep(i, m){
    int x, y;
    cin >> x >> y;
    --x, --y;
    g[x].pb(y);
    g[y].pb(x);
  }
  bool bad = 0;
  rep(i, n){
    if(!used[i]){
      s1 = 0, s2 = 0;
      dfs(i);
      bad |= (s1 != s2);
    }
  }
  cout << (bad ? "No" : "Yes");
}   
 
int main()
{
  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
    Red;
    int T = 1;
    // cin >> T;
    for(int i = 1; i <= T; ++i){
      solve();
    }
    return 0;
  
}