#include<iostream>
#include<unordered_set>
#include<vector>
#include<cstring>
#include<algorithm>

#define maxn 100005

using namespace std;

int couple[maxn];

int main(){
   
	int n;
	cin>>n;
	fill(couple,couple+maxn,-1);
	for(int i=0;i<n;i++)
	{
   
		int a,b;
		cin>>a>>b;
		couple[a]=b;
		couple[b]=a;
	}	
	int k;
	cin>>k;
	unordered_set<int> s;
	for(int i=0;i<k;i++){
   
		int a;
		cin>>a;
		s.insert(a);
	}
	vector<int> dog;
	for(auto it=s.begin();it!=s.end();it++)
	{
   
		if(couple[*it]<0||s.find(couple[*it])==s.end())
		{
   
			dog.push_back(*it);
		}
	}
	if(dog.empty())
	{
   
		cout<<"0\n";
		return 0;
	}	
	else 
	cout<<dog.size()<<"\n";
	sort(dog.begin(),dog.end());
	for(int i=0;i<dog.size();i++)
	{
   
		if(i) cout<<" ";
		printf("%05d",dog[i]);
	}
}