//Guruguruよりも実装は簡単。考察は難しめ。総合的に見て自分にとっての解きやすさは同じくらい。
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;
typedef pair<int, string> P;

int n;
P drink[100000];
int m;
string color[100000];

int main() {
	int i;
	
	cin >> n;
	rep(i, n) { cin >> drink[i].second >> drink[i].first; }
	sort(drink, drink + n);
	
	cin >> m;
	rep(i, m) { cin >> color[i]; }
	
	int w = -114514, id = 0;
	rep(i, n) {
		if (drink[i].first <= w) continue;
		if (id < m && drink[i].second == color[id]) {
			w = drink[i].first;
			id++;
		}
	}
	
	if (id == m) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}
