#!/usr/bin/python

"""
   Simple filter
"""

import sys

need = set()
for i in open(sys.argv[1]):
	need.add(i.rstrip())

for i in open(sys.argv[2]):
	fields = i.rstrip().split("\t")
	if fields[1] in need:
		print i.rstrip()
