#include <bits/stdc++.h>
#include <algorithm>
#include <unordered_map>
#define ull unsigned long long
#define int long long
#define ll long long
#define fr(i, n) for (int i = 0; i < n; i++)
#define frf(i, j, n) for (int i = j; i <= n; i++)
#define frd(i, n) for (int i = n; i >= 0; i--)
#define mp(i, j) make_pair(i, j)
#define pb(x) push_back(x)
#define INF 1e18
using namespace std;
typedef pair<int, int> pi;
const int MAX = 1e6 + 1;
// typedef vector<vector<ll>> matrix;
const ll PRIME = 1e9 + 7;
typedef pair<int,pair<int,int> >  ppi;
// const ll MAX = 1e6 + 1;
int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}


int a[MAX]; 
int b[MAX]; 
vector<int>graph[MAX];
vector<bool>vis(MAX,0);
// vector<bool> connected(MAX,0);
pi dfs(int src)
{
    vis[src]=1;
    pi temp;
    temp.first+=a[src];
    temp.second+=b[src];
    for(int i: graph[src])
    {
        if(!vis[i])
        {
          pi tmp2=dfs(i);
        temp.first+=tmp2.first;
        temp.second+=tmp2.second;
        }
    }
    return temp;
    
}
void solve()
{
    int n,m;
    cin>>n>>m;
    // int a[n],b[n];
    int sum1=0,sum2=0;
    fr(i,n)
    {
        cin>>a[i];
        sum1+=a[i];
    }
    // int st;
    bool flag=0;
    fr(i,n)
    {
        cin>>b[i];
        sum2+=b[i];
        if(a[i]!=b[i])
        {   flag=1;
        }   
        

    }
    
    int u,v;
    while(m--)
    {
        cin>>u>>v;
        u--,v--;
        graph[u].pb(v);
        graph[v].pb(u);
    }
    if(sum1!=sum2)
    {
        cout<<"No\n";
        return;

    }
    if(flag==0)
    {cout<<"Yes\n";return;}
//  cout<<st;
   
   
    fr(i,n)
    {
        if(!vis[i])
        {
            pi temp=dfs(i);
            if(temp.first!=temp.second)
            {
                cout<<"No\n";
                return;
            }
        }
    }
    cout<<"Yes\n";


}

 

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t;
    t = 1;
    // cin >> t;

    // int k=1;
    while (t--)
    {
        // cout << "Case " << k++ << ":\n";
        solve();
    }
}
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < int , int >
#define F first
#define S second
#define endl '\n'
#define int long long
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#define kill(x) return cout<<x<<'\n', 0;
using namespace std;
const int N=2e5+100;
vector <int> g[N];
ll a[N];
ll b[N];
ll vis[N];
ll p1=0,p2=0;
void dfs(ll v){
    vis[v]=1;
    p1+=a[v];
    p2+=b[v];
    for (auto u : g[v]){
        if (!vis[u]) dfs(u);
    }
    return ;
}
int32_t main(){
    ll 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;i<m;i++){
        ll u,v;
        cin >> u >> v;
        g[u].pb(v);
        g[v].pb(u);

    }
    for (int i=1;i<=n;i++){
        if (!vis[i]){
            dfs(i);
            if (p1!=p2) kill("No");
        }
    }
    kill("Yes");

}
