#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int c, long long int d) {
  if (d == 0)
    return c;
  else
    return gcd(d, c % d);
}
struct name {
  string a;
  int id;
} arr[2 * 100000 + 2];
int per[100000 + 2];
bool cmp(name x, name y) { return x.a < y.a; }
int main() {
  int n;
  cin >> n;
  int id1 = 0;
  for (int i = 1; i <= n; i++) {
    cin >> arr[id1++].a >> arr[id1++].a;
    arr[id1 - 1].id = i;
    arr[id1 - 2].id = i;
  }
  memset(per, 0, sizeof per);
  for (int i = 1; i <= n; i++) {
    cin >> per[i];
  }
  sort(arr, arr + id1, cmp);
  int cnt = 0, id2 = 1;
  for (int i = 0; i < id1; i++) {
    if (per[id2] == arr[i].id) {
      id2++;
    }
  }
  if (id2 == n + 1) {
    cout << "YES" << endl;
  } else
    cout << "NO" << endl;
  return 0;
}
