#include <bits/stdc++.h>

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
#if __cplusplus <= 201402L
template <typename T>
T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;

class Solver2 {
 public:
  int n, m;
  vector<vector<int>> g, ans;
  vector<int> cnt, dep;
  vector<pair<int, int>> edge;
  Solver2(LL n, LL m) : n(n), m(m), g(n), ans(n, vector<int>(n)), cnt(n), dep(n, -1){};

  void solve() {
    for (int i = 0; i < m; ++i) {
      int a, b;
      cin >> a >> b;
      g[--a].push_back(--b);
      g[b].push_back(a);
      edge.emplace_back(a, b);
    }
    for (int i = 0; i < n; ++i) {
      cin >> cnt[i];
    }
    for (int i = 0; i < n; ++i) {
      if (dep[i] < 0) {
        dfs(i, -1, 0);
      }
    }

    for (int i = 0; i < m; ++i) {
      if (cnt[edge[i].first] > cnt[edge[i].second]) {
        //|| (cnt[edge[i].first] == cnt[edge[i].second] && dep[edge[i].first] < dep[edge[i].second])) {
        ans[edge[i].first][edge[i].second] = 1;
      } else if (cnt[edge[i].first] < cnt[edge[i].second]) {
        ans[edge[i].first][edge[i].second] = -1;
      }
    }
    DBG(ans)
    for (int i = 0; i < m; ++i) {
      if (ans[edge[i].first][edge[i].second] > 0) {
        cout << "->" << endl;
      } else {
        cout << "<-" << endl;
      }
    }
  }
  void dfs(int c, int p, int d) {
    dep[c] = d;
    for (auto v : g[c]) {
      if (v != p && cnt[v] == cnt[c]) {
        if (ans[c][v] == 0) {
          ans[c][v] = 1;
          ans[v][c] = -1;
        }
        if (dep[v] < 0) dfs(v, c, d + 1);
      }
    }
  }
};
}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(12);
  long long n = 0, m;
  std::cin >> n >> m;

  Problem::Solver2 sol(n, m);
  sol.solve();
  return 0;
}

#include <iostream>
#include <math.h>
#include <iomanip>
#include <bits/stdc++.h>
#include <string.h>
#include <string>
#include <algorithm>
#define ll long long int
#define pb push_back
#define mem(a,b) memset(a,b,sizeof(a))

using namespace std;

ll binomialCoeff(ll n,ll k)
{
    ll res = 1;
    if(k >n - k)
        k = n - k;
    for(int i = 0; i < k; ++i)
    {
        res *= (n - i);
        res /= (i + 1);
    }
    return res;
}

ll power(ll x,ll y)
{
    ll temp;
    if(y == 0)
        return 1;
    temp = power(x, y/2);
    if (y%2 == 0)
        return (temp*temp);
    else
        return (((x*temp))*temp);
}


//nCr % mod
//const int N0 = 2e5 + 5;
//ll fact[6*N0];
//ll inv[6*N0],invfac[6*N0];
//ll mod = 1e9 + 7;
//
//void factorial()
//{
//    fact[0] = invfac[0] = fact[1] = invfac[1] = 1;
//    inv[1] = 1;
//    for(int i=2;i<=5*N0 + 10;i++)
//    {
//        fact[i] = (fact[i-1]*i)%mod;
//        inv[i] = (inv[mod%i]*(mod - mod/i))%mod;
//        invfac[i] = (invfac[i-1]*inv[i])%mod;
//    }
//}

vector<ll> primes;

void Sieve(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));
    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p])
          primes.push_back(p);
}

//******************************************************    CHECK CONSTRAINTS   ***************************************************************//

const int N = 2e5 + 5;

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;
    cin >> n;
    int l[n+1],r[n+1];
    int b[2*n + 1] = {0};
    bool bad = 0;
    bool dp[2*n + 1] = {0};
    for(int i=1;i<=n;i++)
    {
        cin >> l[i] >> r[i];
        if(l[i]!=-1)
        {
            if(b[l[i]])
                bad = 1;
            b[l[i]] = i;
        }
        if(r[i] != -1)
        {
            if(b[r[i]])
                bad = 1;
            b[r[i]] = i;
        }
        if(r[i]!=-1 && l[i] > r[i])
            bad = 1;
    }
    dp[0] = 1;
//    for(int i=1;i<=2*n;i++)
//        cout << b[i] << " ";
//    cout << "\n";
    if(bad)
        return cout << "No",0;
    for(int i=1;i<=2*n;i+=2)
    {
        bool found = 0;
        for(int len = 2;len + i - 1<= 2*n;len += 2)
        {
            int f = 0;
            bool good = 1;
            int k = len/2;
            for(int j = i;j <= i - 1 + k;j++)
            {
                int x = b[j];
                int y = b[j+k];
                if(x == 0 && y == 0)
                    continue;
                if(x && y)
                {
                    if(x != y)
                    {
                        good = 0;
                        break;
                    }
                    f = 1;
                }
                if(y==0)
                {
                    if(r[x] != -1)
                    {
                        good = 0;
                        break;
                    }
                }
                if(x==0)
                {
                    if(l[y] != -1)
                    {
                        good = 0;
                        break;
                    }
                }
            }
            //cout << i << " " << len << " " << good << "\n";
            if(good)
            {
                found = 1;
                dp[i + len - 1] |= dp[i-1];
                //cout << i << " " << len << " " << dp[i-1] << " " << dp[i + len - 1] <<  '\n';
            }
        }
    }
//    for(int i=1;i<=2*n;i++)
//        cout << dp[i] << " ";
//    cout << "\n";
    if(dp[2*n])
        cout << "Yes";
    else
        cout << "No";
}
