单身狗
cp = int(input())
cps = []
for i in range(cp):
cps.append(input().split())
input()
p = set(input().split())
for i in cps:
if i[0] in p and i[1] in p:
p.remove(i[0])
p.remove(i[1])
p = list(p)
p.sort()
if len(p)== 0:
print(0,end = '')
else:
print(len(p))
print(' '.join(p))