N, M, K = map(int, raw_input().strip().split()) abcs = [list(map(int, raw_input().strip().split())) for i in range(M)] ds = map(int, raw_input().strip().split()) D = [[set() for j in range(N+1)] for i in range(N+1)] for abc in abcs: a, b, c = abc D[a][b].add(c) D[b][a].add(c) def dfs(s, lst): if not lst: return [s] return [x for t in range(N+1) if lst[0] in D[s][t] for x in dfs(t, lst[1:])] ss = set(j for i in range(N+1) for j in range(N+1) if ds[0] in D[i][j]) ans = sorted(set(z for s in ss for z in dfs(s, ds[1:]))) L = len(ans) print(L) if L == 0: print(ans[0]) else: print(' '.join(map(str, ans)))