n, m = map(int, input().split()) n_dict = dict() m_dict = dict() result = [] for i in range(n): n_dict[input()] = 0 for i in range(m): m_dict[input()] = 0 for i in n_dict: if i in m_dict: result.append(i) result.sort() print(len(result)) for i in result: print(i)