#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
#include<array>

#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
#define all(v) (v).begin(),(v).end()
#define debug(x) cout << #x << ": " << x << '\n';
#define degreeToRadian(deg) (((deg)/360)*2*M_PI)
#define radianTodegree(rad) (((rad)/2/M_PI)*360)

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using PL = pair<ll, ll>;
const ll INF = 1LL<<60;
const int MOD = 1e9 + 7;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

struct UnionFind {
  int n;
  vector<int> a;
  vector<int> sz;

  UnionFind(int _n) : n(_n), a(_n), sz(_n, 1) {
    for(int i = 0; i < _n; i++) a[i] = i;
  }

  int root(int x) { 
    if (a[x] == x) return x;
    return a[x] = root(a[x]);
  }

  void unite(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    if (rx == ry) return;
    if (sz[rx] < sz[ry]) swap(rx, ry);
    sz[rx] += sz[ry];
    a[ry] = rx;
  }

  bool same(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }

  int size(int x) {
    return sz[root(x)];
  }

  map<int, vector<int>> groups() {
    map<int, vector<int>> group;    
    rep (i, n) root(i);
    rep (i, n) group[a[i]].push_back(i);
    return group;
  }
};


int main() {
  //cin.tie(0);ios::sync_with_stdio(false);
  //cout << fixed << setprecision(15);
  int N, M;
  cin >> N >> M;
  UnionFind uf(N);
  vector<int> 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;
    uf.unite(c, d);
  }

  for (auto v : uf.groups()) {
    ll x = 0, y = 0;
    for (auto vv : v.second) {
      x += a[vv];
      y += b[vv];
    }
    if (x == y) continue;

    cout << "No" << endl;
    return 0;
  }

  cout << "Yes" << endl;
  return 0;
}

#include <iostream>
#include <bits/stdc++.h>

using namespace std;

#define ll long long int
#define ld long double
#define MAX 205
#define MOD 998244353
#define INF 1e15
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi 3.14159265358979323846
#define Q ll MAXTEST; cin >> MAXTEST; for(ll TEST=1;TEST<=MAXTEST;TEST++)
#define endl "\n"
#define coutyes cout << "Yes\n";
#define coutno cout << "No\n";
#define flush fflush(stdout);
#define fixedprec cout << fixed << setprecision(18);

int main(){

    fast

    ll n,m;
    cin >> n >> m;
    ll b[m+1];
    for(ll i=1;i<=m;i++){
        cin >> b[i];
    }
    if(!m){
        cout << 1 << endl;
        return 0;
    }
    sort(b+1,b+m+1);
    vector<ll> a;
    for(ll i=1;i<=m;i++){
        ll tmp;
        if(i==1){
            tmp = b[i]-1;
        }
        else{
            tmp = b[i]-b[i-1]-1;
        }
        if(tmp>0){
            a.push_back(tmp);
        }
    }
    if(n-b[m]>0){
        a.push_back(n-b[m]);
    }

    ll n1 = a.size();
    ll ans = 0;
    if(!n1){
        cout << 0 << endl;
        return 0;
    }
    sort(a.begin(),a.end());
    for(ll i=0;i<n1;i++){
        ll tmp = a[i]/a[0];
        if(a[i]%a[0]){
            tmp++;
        }
        ans+=tmp;
    }
    cout << ans << endl;

}
