n,m,k=map(int,input().split()) l=[list(map(int,input().split())) for i in range(m)] d=list(map(int,input().split())) d.reverse() c=[[] for i in range(n)] for i in range(m): c[l[i][0]-1].append((l[i][1]-1,l[i][2])) c[l[i][1]-1].append((l[i][0]-1,l[i][2])) ans=[] for i in range(n): p=[i] for j1 in range(k): p2=set() for j2 in range(len(p)): for j3 in range(len(c[p[j2]])): if c[p[j2]][j3][1]==d[j1]: p2.add(c[p[j2]][j3][0]) p=list(p2) if len(p)>0: ans.append(str(i+1)) print(len(ans)) print(' '.join(ans))