#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
#define inf 1e9


int main(){
	int n;
	cin>>n;
	int color = 0;

	map<string,int> t;
	vector<priority_queue<int,vector<int> ,greater<int> > > tt;
	for(int i=0;i<n;i++){
		string s;
		int d;
		cin>>s>>d;
		if(t.find(s) == t.end() ){
			priority_queue<int,vector<int> ,greater<int> > q;
			t[s] = tt.size();
			q.push(d);
			tt.push_back(q);
		}else{
			int ss = t[s];
			tt[ss].push(d);
		}
	}

	int m;
	cin>>m;
	bool f = false;
	int now = -1;
	for(int i=0;i<m;i++){
		string s;
		cin>>s;
		if(f)continue;
		if(t.find(s) == t.end()){
			//cout<<"color not exsit"<<endl;
			f = true;
			continue;
		}
		int ss = t[s];
		if(tt[ss].empty() ){
			//cout<<"color used "<<endl;
			f = true;
			//cout<<1<<endl;
			continue;
		}
		int next=tt[ss].top();
		tt[ss].pop();
		//cout<<s<<' '<<next<<endl;
		while(now  >= next){
			if(tt[ss].empty() ){
				f = true;
				break;
			}
			next = tt[ss].top();
			tt[ss].pop();
			//cout<<now<<' '<<next<<endl;
			//cout<<2<<endl;
			continue;
		}
		now = next;
	}
	if(f){
		cout<<"No"<<endl;
	}else{
		cout<<"Yes"<<endl;
	}

	return 0;
}

