#include<bits/stdc++.h>
#include<cstring>
//#define Mfc_Tanzim
#define   ll         long long
#define   ull        unsigned long long
#define   pb         push_back
#define   ff         first
#define   ss         second
#define   all(v)     (v.begin(), v.end())
#define   rall(v)    (v.rbegin(), v.rend())
#define   pi         acos(-1.0)
#define   FastRead   ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define   bug(a)     cerr << #a << " : " << a << endl
using namespace std;
const ll mod = 1e9+7;
const ll mx = 2e6+10;

int posx[] = {1,-1, 0, 0};
int posy[] = {0, 0, 1,-1};
ll x, y, arr[mx], arr2[mx];
vector<ll>graph[mx];
map<ll, bool>vis;

void Dfs(int src)
{
    x+=arr[src], y+=arr2[src];
    vis[src] = true;
    for(auto x: graph[src]){
              if(!vis[x]){
                      Dfs(x);
              }
    }
}

int main()
{
    FastRead

#ifdef Mfc_Tanzim
    freopen("input.txt","r", stdin);
    // freopen("output.txt","w", stdout);
#endif /// Mfc_Tanzim

    ll t=1, n, k, m;
    //cin >> t;

    while(t--){
             cin >> n >> m;

             for(int i=1; i<=n; i++) cin >> arr[i];
             for(int i=1; i<=n; i++) cin >> arr2[i];

             while(m--){
                       ll u, v;
                       cin >> u >> v;
                       graph[u].pb(v);
                       graph[v].pb(u);
             }
             bool ok = true;
             for(int i=1; i<=n; i++){
                       if(!vis[i]){
                               x = y = 0;
                               Dfs(i);
                               if(x!=y) ok = false;
                       }
             }
             cout << (ok? "Yes" : "No") << endl;
    }
    return 0;
}

#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int MOD = 1e9+7;
typedef pair<ll, ll> pairs;
typedef vector<pairs> p;
// #define ALL(obj) (obj).begin(),(obj).end()
struct edge{
    ll to, cost;
};

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

// 数字の桁数
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// べき乗の余り
ll modpow(ll a, ll n){
    ll res = 1;
    while(n){
        if(n & 1){
            res = res * a % MOD;
        }
        a = a * a % MOD;
        n = n >> 1;
    }
    return res;
}

// コンビネーション
ll MAXN = 2e5+10;
vector<ll> inv(MAXN);
ll nCk(ll n, ll k) {
	ll res = 1;
	for(ll i = 1; i <= k; i++) {
		res = res*(n-i+1) % MOD;
	}
 
	for(ll i = 1; i <= k; i++) {
		res = res*inv[i] % MOD;
	}
	return res;
}

// ---------------------------------------------

int main(){
    ll n, m;
    cin>>n>>m;
    vector<ll> a(n), b(n);
    for(ll i=0;i<n;++i){
        cin>>a[i];
    }
    for(ll i=0;i<n;++i){
        cin>>b[i];
    }
    vector<ll> g[n];
    for(ll i=0;i<m;++i){
        ll c, d;
        cin>>c>>d;
        c--; d--;
        g[c].push_back(d);
        g[d].push_back(c);
    }

    vector<bool> d(n, false);
    queue<ll> q;
    string ans = "Yes";
    for(ll i=0;i<n;++i){
        ll sum = 0;
        if(d[i] == false){
            d[i] = true;
            q.push(i);
            sum += b[i] - a[i];
        }else{
            continue;
        }
        while(!q.empty()){
            ll x = q.front();
            q.pop();
            for(auto val : g[x]){
                if(d[val] == true){
                    continue;
                }
                q.push(val);
                sum += b[val] - a[val];
                d[val] = true;
            }
        }
        if(sum != 0){
            ans = "No";
            break;
        }
    }
    cout<<ans<<endl;

    return 0;
}