#include "bits/stdc++.h"

#pragma warning(disable:4996)
using namespace std;



int main() {
	int N;cin>>N;
	map<string,map<int,int>>mps;
	for (int i = 0; i < N; ++i) {
		string st;cin>>st;
		int d;cin>>d;
		mps[st][d]++;
	}
	for (auto m : mps) {
	}
	int M;cin>>M;
	int k=-1;
	bool ok=true;
	for (int i = 0; i < M; ++i) {
		string st;cin>>st;
		auto it=mps[st].upper_bound(k);
		if (it == mps[st].end()) {
			ok=false;
		}
		else {
			k = it->first;
			it->second--;
			if (it->second == 0) {
				mps[st].erase(it);
			}
		}
	}
	if (ok) {
		cout<<"Yes"<<endl;
	}
	else {
		cout<<"No"<<endl;
	}
	return 0;
} 
