import sequtils,strutils type road = tuple[to, cost : int] var N,M,K,a,b,c : int D : seq[int] (N, M, K) = stdin.readline.split.map(parseInt) var town = newSeqWith(N + 1,newSeq[road](0)) P : set[int8] for m in 1..M: (a,b,c) =stdin.readline.split.map(parseInt) town[a].add((b,c)) town[b].add((a,c)) D = stdin.readline.split.map(parseInt) for n in 1..N: P.incl(n.int8) for d in D: var s : set[int8] for p in P: for r in town[p.int]: if r.cost == d: s.incl(r.to.int8) P = s echo P.card var ans = newSeq[int](0) for i in P: ans.add(i) echo ans.join(" ")