#include<bits/stdc++.h>

using namespace std;

using int64 = long long;

void fail() {
  cout << "No\n";
  exit(0);
}

int main() {
  int N;
  cin >> N;
  map< string, priority_queue< int, vector< int >, greater< int > > > C;
  for(int i = 0; i < N; i++) {
    string x;
    int y;
    cin >> x >> y;
    C[x].push(y);
  }
  int M;
  cin >> M;
  int last = -1;
  while(M--) {
    string O;
    cin >> O;
    if(!C.count(O)) fail();
    auto &p = C[O];
    while(C[O].size() && C[O].top() <= last) C[O].pop();
    if(C[O].empty()) fail();
    last = C[O].top();
  }
  cout << "Yes\n";

}

