#!/usr/bin/env python

"""
Filters input: only lines whose first tab-separated field is in the file
specified as command-line argument.
"""

import sys

lineids = set()

with open(sys.argv[1]) as f:
    for line in f:
        lineids.add(line.rstrip())

for line in sys.stdin:
    line = line.rstrip()
    if line.split('\t')[0] in lineids:
        print line
