#include<bits/stdc++.h>
using namespace std;
#define FOR(i,n)             for(ll i=1;i<=n;i++)
#define LOOP(i,n)            for(ll i=0;i<n;i++)
#define loop(a,b)            for(ll i=a;i<=b;i++)
#define sci(n)               scanf("%d",&n)
#define scl(n)               scanf("%lld",&n)
#define scl3(a,b,c)          scanf("%lld%lld%lld",&a,&b,&c);
#define scl2(a,b)            scanf("%lld%lld",&a,&b)
#define scd(n)               scanf("%lf",&n)
#define pf(n)                printf("%lld\n",n)
#define srt(g)               sort(g.begin(),g.end())
#define rvs(g)               reverse(g.begin(),g.end())
#define pl                   pair<long long,long long>
#define pll                  pair<long long,pair<long long,long long>>
#define ll long long
#define pb push_back
#define mp make_pair
#define pi acos(-1.0)
#define f first
#define s second
int main()
{
    ll n,m;
    scl2(n,m);
    vector<ll>a;
    ll x;
    if(m==0)
    {
        cout << "1\n";
        return 0;
    }
    LOOP(i,m)
    {
        scl(x);
        a.pb(x);
    }
    srt(a);
    ll mn=INT_MAX;
    vector<ll>v;
    if(a[0]!=1)
    {
        v.pb(a[0]-1);
        mn=min(mn,a[0]-1);
    }
    for(ll i=0;i<m-1;i++)
    {
        x=a[i+1]-a[i]-1;
        if(x!=0)
        {
            mn=min(mn,x);
            v.pb(x);
        }
    }
    if(a[m-1]!=n)
    {
        v.pb(n-a[m-1]);
        mn=min(mn,n-a[m-1]);
    }
    ll ans=0;
    if(v.size()==0)
    {
        cout << "0\n";
        return 0;
    }
    for(auto x:v)
    {
        //cout << "x" << "\n";
        ll y=x/mn;
        if(x%mn)y++;
        ans=ans+y;
    }
    pf(ans);
}


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

vector<int> seen;
vector<vector<int>> g;
vector<int> a, b;

void dfs(int node, int64_t& sum) {
    seen[node] = 1;
    sum += a[node];
    sum -= b[node];
    for (auto v : g[node])
        if (not seen[v])
            dfs(v, sum);
}

int main() {
    int n, m; cin >> n >> m;
    a = vector<int> (n, 0);
    b = vector<int> (n, 0);

    for (int i = 0; i < n; i += 1)
        cin >> a[i];
    for (int i = 0; i < n; i += 1)
        cin >> b[i];
    
    g = vector<vector<int>> (n);

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

    for (int i = 0; i < n; i += 1) {
        if (not seen[i]) {
            int64_t tot = 0;
            dfs(i, tot);
            if (tot != 0) {
                cout << "No\n";
                return 0;
            }
        }
    }

    cout << "Yes\n";
}