//oct 10,2020
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
#define int                     long long   
#define double                  long double
#define endl                    "\n"
#define pb                      push_back
#define PI                      3.1415926535897932384626433832795l
#define F                       first
#define S                       second
#define mp                      make_pair
#define f(i,n)                  for(int i=0;i<n;i++)
#define loop(i,a,b)             for(int i=a;i<b;i++)        
#define fastio                  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v)                  (v).begin(),(v).end()
#define rall(v)                 (v).rbegin(),(v).rend()
#define gcd(a,b)                __gcd((a),(b))
#define fill(a,value)           memset(a,value,sizeof(a));
#define minn(v)                 *min_element(v.begin(), v.end());
#define maxx(v)                 *max_element(v.begin(), v.end());
#define print(x)                cout<<(x)<<endl;    
#define sum(v)+x                accumulate(v.begin(), v.end(),x);
#define debug(x)                cout<<#x<<'='<<(x)<<endl;
typedef pair<int,int>           pii;
typedef vector<int>             vi;
const int mod=1e9+7; 
const int MOD=998244353;
  

signed main() 
{
    char s;
    cin>>s;
    char t;
    cin>>t;
    if(s=='Y')print((char)toupper(t))
    else print(t)
    
    
    
    
    
	return 0;
}
    
#include<bits/stdc++.h>

using namespace std;

#define FOR(i, x, y) for(int i = (x); i < (y); ++i)
#define REP(i, x, y) for(int i = (x); i <= (y); ++i)
#define PB push_back
#define MP make_pair
#define PH push
#define fst first
#define snd second
typedef long long ll;
typedef unsigned long long ull;
typedef double lf;
typedef long double Lf;
typedef pair<int, int> pii;

const int maxn = 2e5 + 5; 

int n, m;
int a[maxn], b[maxn];

class Dsu{
public:
	int fa[maxn];
	ll f[maxn], g[maxn];
	inline int find(int x){ return (x == fa[x] ? x : (fa[x] = find(fa[x]))); }
	inline void init(){
		FOR(i, 0, maxn)
			fa[i] = i, f[i] = a[i], g[i] = b[i];
		return;
	}
	inline void merge(int u, int v){
		u = find(u); v = find(v);
		if(u == v)
			return;
		f[v] += f[u];
		g[v] += g[u]; 
		fa[u] = v;
		return;
	}
}dsu;

int main(){
	scanf("%d%d", &n, &m);
	FOR(i, 0, n)
		scanf("%d", a + i);
	FOR(i, 0, n)
		scanf("%d", b + i);
	
	dsu.init();
	
	FOR(i, 0, m){
		int u, v;
		scanf("%d%d", &u, &v); --u; --v;
		dsu.merge(u, v);
	}
	
	FOR(i, 0, n) if(dsu.find(i) == i && dsu.f[i] != dsu.g[i]){
		puts("No");
		return 0;
	}
	
	puts("Yes");
	return 0;
}
