
#include <bits/stdc++.h>

using namespace std;

string to_string(string s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    ostringstream name;
    name<<x;
    string l=name.str();
    res += to_string(l);
  }
  res += "}";
  return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

int main()
{
    int n,m;
    scanf("%d %d",&n,&m);
    vector<int>a(n);
    for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}	
	vector<int>b(m);
	for(int i=0;i<m;i++){
		scanf("%d",&b[i]);
	}
	for(int i=1;i<=1e3;i++){
		auto poz = binary_search(a.begin(),a.end(),i) ;
		auto poz2 = binary_search(b.begin(),b.end(),i) ;
		if((poz && !poz2) ||
			(!poz && poz2) ){
			printf("%d ",i);
		}
		
	}
	printf("\n");


    return 0;
}


#include <iostream>
#include <fstream>
#include <cstdio>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <string.h>
#include <string>
#include <math.h>
#include <iomanip>
#include <cassert>
#include <random>
#include <time.h>
using namespace std;

#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define REVERSE(v) reverse((v).begin(), (v).end())
#define pb push_back
#define FOR(i, n) for(int i = 0; i < (n); i++)
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;

const int mod = 1e9 + 7;
const int mod2 = 998244353;

void fact_init(int n, int md);
ll exp(ll taban, ll us, ll md);
ll ebob(ll a, ll b);
ll ekok(ll a, ll b);
ll komb(int a, int b, int md);
ll mul(ll a, ll b, int md);

vector<ll> fact;
vector<ll> inv_fact;
void fact_init(int n, int md){
    fact.resize(n+5);
    inv_fact.resize(n+5);
    fact[0] = inv_fact[0] = 1;
    for(int i = 1; i <= n; i++){
        fact[i] = (fact[i-1] * i) % md;
        inv_fact[i] = exp(fact[i], md-2, md);
    }
}
ll exp(ll taban, ll us, ll md) {
    ll carpan = taban % md;
    if(carpan == 0) return 0;
    ll temp = us;
    ll res = 1;
    while(temp){
        if(temp % 2) res = (res*carpan) % md;
        temp /= 2;
        carpan = (carpan*carpan) % md;
    }
    return res;
}
 
ll ebob(ll a, ll b){
    if(!a)return b;
    return ebob(b%a, a);
}

ll ekok(ll a, ll b){
    return (a*b)/ebob(a, b);
}

ll komb(int a, int b, int md){
    if(a < b) return 0;
    return fact[a] * (inv_fact[a-b] * inv_fact[b] % md) % md;
}

ll mul(ll a, ll b, int md){
	return a*b % md;
}
const int N = 2e5 + 5;
vector<vector<int>> g(N);
int a[N], b[N];
bool vis[N];
int main(){
    ios::sync_with_stdio(false); cin.tie(NULL);
	int n, m; cin>>n>>m;
	for(int i = 1; i <= n; i++) cin>>a[i];
	for(int i = 1; i <= n; i++) cin>>b[i];
	for(int i = 0; i < m; i++){
		int u, v; cin>>u>>v;
		g[u].pb(v);
		g[v].pb(u);
	}
	bool check = true;
	for(int i = 1; i <= n; i++){
		if(vis[i]) continue;
		queue<int> q;
		q.push(i);
		vis[i] = true;
		vector<int> cur_nodes;
		while(!q.empty()){
			int cur = q.front();
			q.pop();
			cur_nodes.pb(cur);
			for(int node: g[cur]){
				if(vis[node]) continue;
				vis[node] = true;
				q.push(node);
			}
		}
		ll sum1 = 0, sum2 = 0;
		for(int node: cur_nodes){
			sum1 += a[node];
			sum2 += b[node];
		}
		check &= sum1 == sum2;
	}
	cout<<(check ? "Yes\n" : "No\n");
}