#include<bits/stdc++.h>
using namespace std;
#define mst(x,y) memset(x,y,sizeof(x))
#define rep(x,y,z) for(int x=(y);(x)<(z);x++)
const int maxn=1e5;
int a[maxn];
int n,x,y;
vector<int> g[maxn];
vector<int> ans;
int tmp[maxn];
int main(){
scanf("%d",&n);
rep(i,0,n){
scanf("%d%d",&x,&y);
g[x].push_back(y);
g[y].push_back(x);
}
int k;scanf("%d",&k);
rep(i,0,k){
scanf("%d",&tmp[i]);
a[tmp[i]]=1;
}
rep(i,0,k){
if(g[tmp[i]].size()){
int v=g[tmp[i]][0];
if(a[v]==0) ans.push_back(tmp[i]);
}else{
ans.push_back(tmp[i]);
}
}
sort(ans.begin(),ans.end());
printf("%d\n",ans.size());
rep(i,0,ans.size()){
printf("%05d",ans[i]);
if(i!=ans.size()-1) printf(" ");
else puts("");
}
return 0;
}