#include <algorithm>
#include <iostream>
#include <stack>
#include <queue>
#include <math.h>
#include <cmath>
#include <string>
#include <iterator>
#include <map>
#include <set>
#include <iomanip>
#include <vector>
#include <cstdint>
#include <time.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Graph = vector<vector<int>>;
#define rep(i, N) for(int i = 0; i < N; i++)
#define rep2(i, l, r) for (ll i = (ll)l; i < (ll)(r); i++)
#define INF 1000000000000000000
#define MAX 200001
#define PI 3.141592653589793

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
const ll MOD = 1000000007;

/*clock_t start = clock();
clock_t end = clock();
const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;
printf("%lf", time);*/

template <typename T > inline string toString(const T &a) {ostringstream oss; oss << a; return oss.str();};

int par[1000000];

void init(int N){
    rep(i,N) par[i] = -1;
}

int find(int a){
    if(par[a] < 0) return a;
    else{
        return par[a] = find(par[a]);
    }
}

void unite(int a, int b){
    a = find(a);
    b = find(b);
    if(a == b) return;
    else{
        if(par[a] > par[b]) swap(a,b);
        par[a] += par[b];
        par[b] = a;
    }
}

int size(int A) {
     return -par[find(A)];
}

bool same(int a, int b){
    return find(a) == find(b);
}

int main(){
    int N,M;
    cin >> N >> M;
    init(N);
    vector<ll> a(N),b(N);
    rep(i,N) cin >> a[i];
    rep(i,N) cin >> b[i];
    rep(i,M){
        int c,d;
        cin >> c >> d;
        c--;d--;
        unite(c,d);
    }   
    map<int,vector<int>> group;
    rep(i,N){
        group[find(i)].push_back(i);
    }
    bool flag = true;
    for(auto g:group){
        auto v = g.second;
        ll A = 0;
        ll B = 0;
        for(auto u:v){
            A += a[u];
            B += b[u];
        }
        if(A != B) flag = false;
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}
#include<bits/stdc++.h>

using namespace std;

const int maxN = 200009;
int N, M, a[maxN], b[maxN];
bool ap[maxN];
long long sumA, sumB;
vector < int > v[maxN];

void dfs (int nod)
{
    ap[nod] = 1, sumA += a[nod], sumB += b[nod];
    for (auto it : v[nod])
        if (!ap[it])
            dfs (it);
}

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d %d", &N, &M);
for (int i=1; i<=N; i++)
    scanf ("%d", &a[i]);
for (int i=1; i<=N; i++)
    scanf ("%d", &b[i]);
while (M --)
{
    int x, y;
    scanf ("%d %d", &x, &y);
    v[x].push_back (y);
    v[y].push_back (x);
}
for (int i=1; i<=N; i++)
    if (ap[i] == 0)
    {
        sumA = 0, sumB = 0, dfs (i);
        if (sumA != sumB)
        {
            printf ("No\n");
            return 0;
        }
    }
printf ("Yes\n");
return 0;
}
