#include <bits/stdc++.h>
typedef struct {
  char fn[55];
  int pos;
} Handle;
Handle h[200005];
int compare(const void *a, const void *b) {
  Handle *e1 = (Handle *)a;
  Handle *e2 = (Handle *)b;
  return strcmp(e1->fn, e2->fn);
}
int main() {
  int n, i, p[100005], j;
  scanf("%d", &n);
  j = 1;
  for (i = 1; i <= 2 * n; i = i + 2) {
    scanf("%s%s", h[i].fn, h[i + 1].fn);
    h[i].pos = j;
    h[i + 1].pos = j;
    j++;
  }
  for (i = 0; i < n; i++) {
    scanf("%d", &p[i]);
  }
  qsort(h, 2 * n + 1, sizeof(Handle), compare);
  j = 0;
  for (i = 1; i <= 2 * n; i++) {
    if (h[i].pos == p[j]) {
      j++;
    }
  }
  if (j < n) {
    printf("NO\n");
  } else {
    printf("YES\n");
  }
  return 0;
}
