#include<bits/stdc++.h>
#include<cmath>
#define tr(v,it) for(typeof(v.begin()) it = v.begin() ;it!=v.end();it++)
#define in(x) lli x; cin>>x
#define all(v) v.begin(),v.end()
#define for0(n) for(lli i=0;i<n;i++)
#define for1(n) for(lli i=1;i<=n;i++)
#define mod 1000000007
#define asc_ord_set tree< lli , null_type,less<lli>, rb_tree_tag,tree_order_statistics_node_update>
#define desc_ord_set tree< lli , null_type, greater<lli>, rb_tree_tag,tree_order_statistics_node_update>
#define key_position(k,o) o.order_of_key(k)
// Common file
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long int lli;
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef unordered_map <lli,lli> umap;
typedef priority_queue<lli> pq;
typedef pair <lli, lli> pi;
bitset<10000000> p;
bool sieve_made = false;
lli fast_power(lli a,lli b)
{
    lli p = a;
    lli res = 1;
    while(b>0)
    {
        if(b&1)
            res*= p;
        p= p*p;
        b= b>>1;
    }
    return res;
}
void sieve()
{   sieve_made=true;
    p[0] = p[1] = 0;
    p[2] = 1;
    for(lli i=4;i<=1000000;i+=2)
        p[i] = 0;
    for(lli i=3;i<=1000000;i+=2)
    {
        if(p[i])
        {
            for(lli j=i*i;j<=1000000;j+=i)
                p[j] = 0;
        }
    }
}
bool prime(lli n)
{
    if(sieve_made==true)
    {
        if(n<10000000)
            return (p[n]);
        else{
             for(int i=2;i<=sqrt(n);i++)
                    if(n%i==0) return false;
            return true;
        }
    }
    for(int i=2;i<=sqrt(n);i++)
        {
            if(n%i==0) return false;
        }
    return true;
}
map <lli,lli> factor;
void prime_fact(lli n)
{
    for(int i=2;i<=int(sqrt(n));i++)
    {
        if(n%i==0)
        {
            while(n%i==0)
                {
                    factor[i]++;
                    n = n/i;
                }
        }
    }
    if(n!=1) factor[n] = 1;
}
int main()
{   ios::sync_with_stdio(false);
    in(n);
    in(m);
    if(m==0)
        {cout<<1;
        return 0;}
    lli arr[m];
    for0(m)
        cin>>arr[i];
    sort(arr,arr+m);
    // now generate the minimum sized
    // cluster
    lli k;
    if(arr[0]-1!=0)
        k = arr[0] - 1;
    else
        k=1e18;
    for(int i=1;i<m;i++){
        if(arr[i]-arr[i-1]-1 != 0)
            k = min(k, arr[i] - arr[i-1] - 1);
        //cout<<arr[i]<<" ";
    }
    if(n-arr[m-1]!=0)
        k = min(k,n - arr[m-1]);
    // k is the minimum sized cluster
    if(m>=n)
        {cout<<0<<endl;
        return 0;}
    lli ans = (arr[0]-1)/k + ((arr[0]-1)%k == 0? 0 : 1);
    for(int i=1;i<m;i++){
        lli size = arr[i] - arr[i-1] - 1;
        ans+= size / k;
        if(size%k!=0)
            ans++;
    }
    ans += (n-arr[m-1])/k;
    if((n-arr[m-1])%k!=0)
        ans+=1;
    cout<<ans;
    return 0;
}

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

#define ll long long int
#define ull unsigned long long int
#define db double
#define ld long double
#define MOD 1000000007
#define inf (1LL << 62)
#define pi acos(-1.0)
#define si(a) scanf("%lld",&a)
#define sd(n) scanf("%lf", &n)
#define for1(i, stop) for(ll i = 1; i <= stop; i++)
#define for0(i, stop) for(ll i = 0; i < stop; i++)
#define rep1(i, start) for(ll i = start; i >= 1; i--)
#define rep0(i, start) for(ll i = (start-1); i >= 0; i--)
#define loop(i, start, stop, inc) for(ll i = start; i <= stop; i += inc)
#define pb(v,a) v.push_back(a)
#define pll pair <ll, ll>
#define mp make_pair
#define pbp(v,a,i) v.push_back(make_pair(a,i))
#define srt(v) sort(v.begin(),v.end())
#define rv(v) reverse(v.begin(),v.end())
#define ms(n, i) memset(n, i, sizeof(n))
#define debug printf("Debug\n");
#define en '\n'



#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
/*typedef tuple<ll,ll,ll>tpl;

ll bigmod(ll n,ll pow)
{
    if(pow==0)
        return 1;
    if(pow==1)
        return n%MOD;

    ll ans=bigmod(n,pow/2);
    ans=(ans*ans)%MOD;

    if(pow%2==1)
    {
        ans=(ans*n)%MOD;
    }
    return ans%MOD;
}

ll fact[1000005];

ll nCr(ll n,ll r)
{

    ll ans=fact[n];
    ans=(ans*bigmod(fact[r],MOD-2))%MOD;
    ans=(ans*bigmod(fact[n-r],MOD-2))%MOD;
    return ans;
} */

/*ll NcR(ll n, ll r) 
{ 
    ll p = 1, k = 1; 
    if (n - r < r) 
        r = n - r; 
  
    if (r != 0) 
    { 
        while (r) 
        { 
            p *= n; 
            k *= r; 
            ll m = __gcd(p, k); 
            p /= m; 
            k /= m; 
  
            n--; 
            r--; 
        } 
    } 
    else
        p = 1;

    return p; 
} */

ll a[200005],b[200005];
vector<ll> adj[200005];
ll bfs_flag[200005];

bool fl=true;

void addEdge(ll x,ll y)
{
    pb(adj[x],y);
    pb(adj[y],x);
}

ll BFS(ll s)
{
    priority_queue<ll, vector<ll>, greater<ll> > Q;
    Q.push(s);
    bfs_flag[s]=1;

    ll sm=0;
    sm+=b[s];
    while(!Q.empty())
    {
        ll u=Q.top();
        Q.pop();
        for(ll i=0;i<adj[u].size();i++)
        {
            ll x=adj[u][i];
            //cout<<x<<" "<<bfs_flag[x]<<en;
            if (bfs_flag[x] ==0)
            {
                Q.push(x);
                bfs_flag[x] =1;
                sm+=b[x];
            }
        }
    }
    return sm;
}


int main()
{
    _fastio
    ll n,m,x,y,fl=0;
    cin>>n>>m;
    for1(i,n) cin>>a[i];
    for1(i,n) {cin>>b[i]; b[i]=b[i]-a[i];}

    for1(i,m)
    {
        cin>>x>>y;
        addEdge(x,y);
    }
    for1(i,n)
    {
        if(bfs_flag[i]==0)
        {
            ll sm=BFS(i);
            //cout<<sm<<en;
            if(sm!=0)
            {
                fl=1;
                break;
            }
        }
    }
    if(fl==1) cout<<"No"<<en;
    else cout<<"Yes"<<en;
}
