#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <cstring>
#include <list>  
#include <cassert>
#include <climits>
#include <bitset>
#include <chrono>
#include <random>
using namespace std;

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
std::mt19937 rnd((int)std::chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }

const int MAXN = 200000;

int n, m;
int s[MAXN], t[MAXN];
vector<int> adj[MAXN];

bool done[MAXN];
int q[MAXN], qhead, qtail;

bool solve() {
	REP(i, n) done[i] = false;
	REP(i, n) if (!done[i]) {
		qhead = qtail = 0; q[qhead++] = i, done[i] = true; ll ssum = 0, tsum = 0;
		while (qtail < qhead) {
			int at = q[qtail++];
			ssum += s[at], tsum += t[at];
			REPSZ(j, adj[at]) {
				int to = adj[at][j];
				if (!done[to]) done[to] = true, q[qhead++] = to;
			}
		}
		if (ssum != tsum) return false;
	}
	return true;
}

void run() {
	scanf("%d%d", &n, &m);
	REP(i, n) scanf("%d", &s[i]);
	REP(i, n) scanf("%d", &t[i]);
	REP(i, m) { int a, b; scanf("%d%d", &a, &b); --a, --b; adj[a].PB(b); adj[b].PB(a); }
	printf("%s\n", solve() ? "Yes" : "No");
}

int main() {
	run();
	return 0;
}

//Author: master19
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long int
#define ff first 
#define ss second 
#define pb push_back
#define endl "\n"
#define mod 1000000007LL // fixed...
#define modd 1000000007LL // Can be changed for global use
#define all(arr) arr.begin(),arr.end()
#define x(arr) arr.begin(),arr.end()
#define ulli unsigned long long int
#define assign(x,val) memset(x,val,sizeof(x))
#define prec(val, dig) fixed << setprecision(dig) << val
#define Sort(arr) sort(arr.begin(), arr.end())
#define time() std::chrono::high_resolution_clock::now();
#define lower(str) transform(str.begin(), str.end(), str.begin(), ::tolower);
#define upper(str) transform(str.begin(), str.end(), str.begin(), ::toupper);
#define crap ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define get(arr, num) vector < ll > arr(num); for(int i=0; i<num; i++)cin >> arr[i];
#define get_set(arr, num, st, type) set < type > st; for(int i=0; i<num; i++) st.insert(arr[i]);
#define put(arr, num) for(int i=0; i<num; i++)cout << arr[i] << " "; cout << endl;
#define Time(start, finish) std::chrono::duration<double> elapsed = finish - start; cout << elapsed.count() << endl;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update > new_ds; 
void debug_out() { cerr << endl; }
template <typename HeadStart, typename... TailEnd>
void debug_out(HeadStart H, TailEnd... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
ll lets_do_it();
ll dx[] = {-1, 1, 0, 0};
ll dy[] = {0, 0, -1, 1};
pair < ll, ll > dig[] = {{-1, -1}, {-1, 1}, {1, 1}, {1, -1}};
bool isValid(ll x, ll y, ll row, ll col){
    return ((x>=0) && (y >=0)  && (x < row) && (y < col));
}
int main(int argc, const char** argv) {
    crap;
    ll test = 1;
    // cin >> test;
    auto start = std::chrono::high_resolution_clock::now();
    for(int loop=0; loop<test; loop++){
        // cout << "Case #" << (loop+1) << ": "; 
        lets_do_it();
    }
    auto finish = std::chrono::high_resolution_clock::now();
    std::chrono::duration<double> elapsed = finish - start;
    cerr << "Game is on :-> " << elapsed.count() << "s"<< endl;
    return 0;
}
ll dfs(vector < vector < ll > > & graph, vector < ll > & init, vector < ll >& final, vector < bool > & visit, ll start, ll *left, ll *right){
    *left += init[start-1];
    *right += final[start-1];
    visit[start] = true;
    for(int i=0; i<graph[start].size(); i++){
        if(!visit[graph[start][i]]){
            dfs(graph, init, final, visit, graph[start][i], left, right);
        }
    }
    return 0;
}
bool dfsHelper(vector < vector < ll > > &graph, vector < ll >&init, vector < ll >&final){
    vector < bool > visit(graph.size(), false);
    ll left = 0, right = 0;
    bool res = true;
    for(int i=1; i<graph.size(); i++){
        if(!visit[i]){
            left = 0, right = 0;
            dfs(graph, init, final, visit, i, &left, &right);
            if(left == right)
                res = res & true;
            else
                res = res & false;
            // debug(res, i, left, right);
        }
    }
    return res;
}
ll lets_do_it(){
    // Your code goes by here !!
    ll num, val;
    cin >> num >> val;
    get(init, num);
    get(final, num);
    vector < vector < ll > > graph(num+1);
    ll u, v;
    for(int i=0; i<val; i++){
        cin >> u >> v;
        graph[u].pb(v);
        graph[v].pb(u);
    }
    if(dfsHelper(graph, init, final))
        cout << "Yes\n";
    else
        cout << "No\n";
    




    return 0;
}
