# Arup Guha
# 7/12/2012
# Reads in a file with two lists of fruits and prints out all
# fruits in both lists.

def main():

    myFile = open("fruits.txt", "r")
    
    list1 = []
    list2 = []

    # Read in the first list.
    numList1 = int(myFile.readline())
    for i in range(numList1):
        thisFruit = myFile.readline()
        thisFruit = thisFruit[:len(thisFruit)-1]
        list1.append(thisFruit)

    # Read in the second list.
    numList2 = int(myFile.readline())
    for i in range(numList2):
        thisFruit = myFile.readline()
        thisFruit = thisFruit[:len(thisFruit)-1]
        list2.append(thisFruit)

    # Add everything from list1 that's also in list2.
    list3 = []
    for i in range(numList1):
        if list1[i] in list2:
            list3.append(list1[i])

    # Sort and print.
    list3.sort()
    for i in range(len(list3)):
        print(list3[i])
    
main()
