/* Be patient, things will be at their rightful place.
Everything happens for a reason.
It was meant to happen this way, accept it.
And now decide what you can do about it.
*/
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define ip pair<ll,ll>
#define vii vector<ll>
#define vpp vector<ip>
#define vdd vector<ld>
#define vb vector<bool>
#define pi  pair<ll,ip>
#define sc(x) scanf("%lli",&x)
#define hu 200010
#define pq priotity_queue<ll>
#define pqs priority_queue<ll,vii,greater<ll>>
#define ppq priority_queue<ip,vpp,greater<ip>>
#define INF INT_MAX
#define ff first
#define ss second

#define fo(i,k,n) for(ll i=k;i<n;i++) 
using namespace std;
const ll M = 1000000000+7;
//Grid Movement
ll dx[] = {-1, 0, 1, 0};
ll dy[] = {0, -1, 0, 1};

ld Pi= acos(-1);

ll lcm(ll a,ll b)
{
    return (a*b)/(__gcd(a,b));
}

ll mex(ll x, ll y) 
{ 
	ll res = 1;	  
	x = x % M; 
	if (x == 0) return 0; 
	while (y > 0) 
	{ 
		if (y & 1) 
		res = (res*x) % M; 
		y = y>>1; 
		x = (x*x) % M; 
	} 
	return res; 
} 

bool comp(ll comp1,ll comp2)
{
    return comp1>comp2;
}

void yes()
{
    printf("Yes\n");
}

void no()
{
    printf("No\n");
}

ll inv(ll a, ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;
 
    if (m == 1)
      return 0;
 
    while (a > 1)
    {
        int q = a / m;
        int t = m;
        m = a % m, a = t;
        t = y;
        y = x - q * y;
        x = t;
    }
 
    if (x < 0)
       x += m0;
 
    return x;
}

void sieve(ll n)
{
    vii primes(n+1);
    vb is_prime(n+1);
	is_prime.resize(n+1);
	primes.resize(n+1);
 
	is_prime[0] = is_prime[1] = false;
	for(int i = 2; i<=n; i++)
	{
	    if(is_prime[i])
	    {
	    	primes.pb(i);
	        for (int j = i*i; j<=n; j+=i)
	            is_prime[j] = false;
	    }
	}
}

ll n,m;
bool vis[hu]={0};
vii v;
  vii vec[hu];
void dfs(ll i)
{
    v.pb(i);
    vis[i] = 1;
    for(auto it:vec[i])
    {
    if(!vis[it]) dfs(it);
        
    }
    
}



void solve()
{
   
   sc(n);
   sc(m);
   ll a[n],b[n];
   ll s1=0,s2=0;
   fo(i,0,n)
   {
       sc(a[i]);
       
   }
   
   fo(i,0,n)
   {
       sc(b[i]);
       
   }
   
 
   fo(i,0,m)
   {
       ll x,y;
       sc(x);
       sc(y);
       vec[x].pb(y);
       vec[y].pb(x);
   }
   
   
   fo(i,1,n+1)
   {
       v.clear();
       if(!vis[i])
       {
           dfs(i);
       }
       ll s1 = 0;s2=0;
       for(auto it:v)
       {
           s1+=a[it-1];
           s2+=b[it-1];
       }
       if(s1!=s2)
       {
           no();
           return;
       }
   }
   
   yes();
   
}

int main()
{
//	ios_base::sync_with_stdio(0); cin.tie(0);
    ll t=1;
  //  sc(t);
    while(t--) solve();
}




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

const int maxH = 16;
const int maxW = 16;

int config[maxH][maxW];
int h,w,a,b;

long long find_ans(int r,int c,int rem)
{	
	if(rem==0){
		return 1;
	}
	
	if(c == w)
		return 0;
		
	long long ans = 0;
	
	int i1=-1;
	
	for(int i=r;i<h;i++)
	{
		if(config[i][c] == 0)
		{
			i1 = i;
			break;
		}
	}
		
	if(i1 == -1)
		return find_ans(0,c+1,rem);
		
	if(i1+1<h && config[i1+1][c] == 0){
		ans += find_ans(i1+2,c,rem-1);
	}
	
	if(c != w-1)
	{
		config[i1][c+1] = 1;
		ans += find_ans(i1+1,c,rem-1);
		config[i1][c+1] = 0;
	}
	
	ans += find_ans(i1+1,c,rem);
	
	return ans;
}

int main()
{
	cin>>h>>w>>a>>b;
	
	cout<<find_ans(0,0,a)<<endl;
	
	return 0;
}