#!/usr/bin/python from collections import defaultdict n, m, k = map(int, raw_input().split()) G = defaultdict(list) for _ in xrange(m): a, b, c = map(int, raw_input().split()) G[c].append((a-1, b-1)) G[c].append((b-1, a-1)) d = map(int, raw_input().split()) arr = set(xrange(n)) for x in d: arr = {to for fra, to in G[x] if fra in arr} res = list(map(lambda e: e+1, arr)) print len(res) print ' '.join(map(str, res))