func_code_string: #include <bits/stdc++.h>   using namespace std;   struct Person {     int num;     string n1, n2;     string final;     Person(int num = -1) { this->num = num; }     void read(int num = -1) {       this->num = num;       cin >> n1 >> n2;     }   };   const int N = 200000;   Person b[N], a[N];   int p[N];   int n;   bool smaller(Person f, Person s) { return p[f.num] < p[s.num]; }   void fail() {     printf( NO n );     exit(0);   }   const bool D = 0;   int main() {     if (D) {       freopen( test.in ,  r , stdin);       freopen( test.out ,  w , stdout);     } else {     }     scanf( %d , &n);     for (int i = 0; i < n; ++i) {       b[i].read(i);     }     for (int i = 0; i < n; ++i) {       scanf( %d , &p[i]);       --p[i];     }     for (int i = 0; i < n; ++i) {       a[i] = b[p[i]];     }     a[0].final = min(a[0].n1, a[0].n2);     for (int i = 1; i < n; ++i) {       a[i].final = min(a[i].n1, a[i].n2);       if (a[i].final <= a[i - 1].final) {         a[i].final = max(a[i].n1, a[i].n2);         if (a[i].final <= a[i - 1].final) fail();       }     }     printf( YES n );     return 0;   }   