import collections n, m, k = [int(x) for x in input().split()] town = [[] for _ in range(n + 1)] for i in range(m): a, b, c = [int(x) for x in input().split()] town[a] += [(b, c)] town[b] += [(a, c)] d = [int(x) for x in input().split()] cand = set() for i in range(1, len(town)): tovisit = collections.deque() tovisit.append((i, 0)) while len(tovisit) >= 1: now, cnt = tovisit.popleft() if cnt >= len(d): cand.add(now) continue for nex, cost in town[now]: if d[cnt] == cost: tovisit.append((nex, cnt + 1)) res = list(cand) res.sort() print(len(res)) print(*res)