## https://yukicoder.me/problems/no/92 def main(): N, M, K = map(int, input().split()) money_map = {} for _ in range(M): a, b, c = map(int, input().split()) if c not in money_map: money_map[c] = [] money_map[c].append((a - 1, b - 1)) money_map[c].append((b - 1, a - 1)) D = list(map(int, input().split())) array = [True] * N for d in D: new_array = [False] * N for a, b in money_map[d]: new_array[b] |= array[a] array = new_array answer = [] for i in range(N): if array[i]: answer.append(str(i + 1)) print(len(answer)) print(' '.join(answer)) if __name__ == '__main__': main()