#include <bits/stdc++.h>
using namespace std;

void solve() {
  using ll = long long;
  int n, m; cin >> n >> m;
  vector<int> a(n), b(n);
  for(auto &x : a) cin >> x;
  for(auto &x : b) cin >> x;
  vector<vector<int>> g(n);
  while(m--) {
    int c, d; cin >> c >> d; --c, --d;
    g[c].emplace_back(d);
    g[d].emplace_back(c);
  }
  vector<bool> seen(n, false);
  auto dfs = [&](auto dfs, int v) -> complex<ll> {
    complex<ll> ret(a[v], b[v]);
    seen[v] = true;
    for(auto &nv : g[v]) {
      if(!seen[nv]) {
        ret += dfs(dfs, nv);
      }
    }
    return ret;
  };
  for(int i=0; i<n; ++i) {
    if(!seen[i]) {
      auto ret = dfs(dfs, i);
      if(real(ret) != imag(ret)) {
        cout << "No\n";
        return;
      }
    }
  }
  cout << "Yes\n";
}

signed main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  solve();
  return 0;
}

#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;
#define endl "\n"
#define pll pair<ll, ll>
#define pii pair<int, int>
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define vpii vector<pair<int, int>>
#define mems(x, y) memset(x, y, sizeof(x))
#define all(x) (x).begin(), (x).end()
#define forn(i, s, e) for (int i = s; i < (e); ++i)
#define FASTIO                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);
#define FILEIO                          \
    freopen("./input.txt", "r", stdin); \
    freopen("./output.txt", "w", stdout);
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__(d)                                                               \
    for (                                                                       \
        auto blockTime = make_pair(chrono::high_resolution_clock::now(), true); \
        blockTime.second;                                                       \
        debug("%s : %lld ms\n ", d, chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - blockTime.first).count()), blockTime.second = false)
const int M = 1e9 + 7;

const ll OO = (ll)1e18;

template <class T>
T ABS(const T &x) { return x > 0 ? x : -x; }
ll gcd(ll n1, ll n2) { return n2 == 0 ? ABS(n1) : gcd(n2, n1 % n2); }
ll lcm(ll n1, ll n2) { return n1 == 0 && n2 == 0 ? 0 : ABS(n1 * n2) / gcd(n1, n2); }

vi a, b;

ll sum1, sum2;

void dfs(int curr, vector<vi> &adj, vi &vis)
{
    vis[curr] = 1;
    sum1 += a[curr];
    sum2 += b[curr];
    for (int i = 0; i < (int)adj[curr].size(); ++i)
    {
        int next = adj[curr][i];
        if (vis[next])
            continue;
        dfs(next, adj, vis);
    }
}

int main()
{
    FASTIO
#ifdef LOCAL
    FILEIO
#endif
    int n, m;
    cin >> n >> m;
    int in;
    forn(i, 0, n)
    {
        cin >> in;
        a.push_back(in);
    }
    forn(i, 0, n)
    {
        cin >> in;
        b.push_back(in);
    }
    int c, d;
    vector<vi> adj(n + 1);
    forn(i, 0, m)
    {
        cin >> c >> d;
        --c, --d;
        adj[c].pb(d);
        adj[d].pb(c);
    }

    vi vis(n, 0);

    forn(i, 0, n)
    {
        if (vis[i])
            continue;
        sum1 = 0, sum2 = 0;
        dfs(i, adj, vis);
        if (sum1 != sum2)
        {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
    return 0;
}