#include <bits/stdc++.h>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fod(i,a,b) for(int i=a;i>=b;i--)
#define me0(a) memset(a,0,sizeof(a))
#define me1(a) memset(a,-1,sizeof(a))
#define op freopen("in.txt", "r", stdin)
#define op1 freopen("C:\\acm\\Cproj\\in.txt","r",stdin);
#define pr freopen("C:\\acm\\Cproj\\out.txt","w",stdout)
#define pr2 freopen("C:\\acm\\Cproj\\std.txt","w",stdout)
#define pii pair<int,int>
#define Please return
#define AC 0
using namespace std;
const int INF = 0x3f3f3f3f;
typedef long long LL;
template <class T>
void read(T &val) { T x = 0; T bz = 1; char c; for (c = getchar(); (c<'0' || c>'9') && c != '-'; c = getchar()); if (c == '-') { bz = -1; c = getchar(); }for (; c >= '0' && c <= '9'; c = getchar()) x = x * 10 + c - 48; val = x * bz; }
const int mod=998244353;
const int maxn = 1e6+10;

int n,m,a[maxn],q,t;
int b[maxn],c[maxn],fa[maxn],d[maxn];

int find(int x){
    return x==fa[x]?x:fa[x]=find(fa[x]);
}
LL sum[maxn];
int main(){
//    op;
    read(n);read(m);
    fo(i,1,n) read(a[i]);
    fo(i,1,n) read(b[i]);

    fo(i,1,n) fa[i]=i;

    fo(i,1,m) read(c[i]),read(d[i]),fa[find(c[i])]=find(d[i]);

    fo(i,1,n) {
        sum[find(i)]+=a[i];
        sum[find(i)]-=b[i];
    }
    int flag = 0;
    fo(i,1,n) if(sum[i]) flag =1;
    if(flag)puts("No");
    else puts("Yes");



    Please AC;
}
#include <bits/stdc++.h>

#define pb push_back
#define int long long
#define ld long double
using namespace std;
const int M = 1000000007;
const int N = 1008;
vector<int> g[N];
char p[N][N];
bool used[N];
int parent[N];
char ans0[N][N];

void dfs(int v) {
    used[v] = true;
    for (auto u : g[v]) {
        if (!used[u]) {
            parent[u] = v;
            if (p[v][u] != '-') {
                ans0[v][u] = p[v][u];
                ans0[u][v] = p[v][u];
                p[v][u] = '-';
                p[u][v] = '-';
            }
            dfs(u);
        } else if (p[v][u] != '-') {
            ans0[v][u] = p[v][u];
            ans0[u][v] = p[v][u];
            p[v][u] = '-';
            p[u][v] = '-';
        }
    }
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n, m;
    cin >> n >> m;
    vector<int> A(m), B(m);
    for (int i = 0; i < m; i++) {
        cin >> A[i] >> B[i];
        A[i]--;
        B[i]--;
    }
    vector<int> C(n);
    for (int i = 0; i < n; i++) cin >> C[i];
    vector<char> ans(m, '>');
    for (int i = 0; i < m; i++) {
        if (C[A[i]] > C[B[i]]) {
            ans[i] = '>';
        } else if (C[A[i]] < C[B[i]]) {
            ans[i] = '<';
        } else {
            g[A[i]].pb(B[i]);
            g[B[i]].pb(A[i]);
            p[A[i]][B[i]] = '>';
            p[B[i]][A[i]] = '<';
        }
    }
    for (int v = 0; v < n; v++) {
        if (!g[v].empty() && !used[v]) {
            dfs(v);
        }
    }
    for (int i = 0; i < m; i++) {
        if (C[A[i]] == C[B[i]]) {
            ans[i] = ans0[A[i]][B[i]];
        }
        if (ans[i] == '>') {
            cout << "->\n";
        } else {
            cout << "<-\n";
        }
    }
}