N, M, K = gets.split.map &:to_i edges = [] M.times.map{ a, b, c = gets.split.map &:to_i edges << [a, b, c] << [b, a, c] } tollages = gets.split.map &:to_i starts = [] checked = [true] * -~N tollages.each{|tollages| nxt = [false] * -~N edges.each{|a, b, c| nxt[b] = true if checked[a] && c == tollages } checked = nxt } p checked.count(true) puts (1..N).select{|i|checked[i]}*" "