using System.Linq; using System.Collections.Generic; using System; public struct P { public int from { get; set; } public int fee { get; set; } } public class Hello { static void Main() { string[] line = Console.ReadLine().Trim().Split(' '); var n = int.Parse(line[0]); var m = int.Parse(line[1]); var k = int.Parse(line[2]); var d = new Dictionary(); for (int i = 0; i < m; i++) { line = Console.ReadLine().Trim().Split(' '); var a = int.Parse(line[0]); var b = int.Parse(line[1]); var c = int.Parse(line[2]); var p0 = new P { from = a, fee = c }; var p1 = new P { from = b, fee = c }; d[p0] = b; d[p1] = a; } getAns(n, d); } static void getAns ( int n, Dictionary d) { string[] line = Console.ReadLine().Trim().Split(' '); var k = Array.ConvertAll(line, int.Parse); var ans = Enumerable.Range(1, n).ToList(); var ans2 = new List(); foreach(var x in k) { foreach(var y in ans) { var p = new P { from = y, fee = x }; if (d.ContainsKey(p)) ans2.Add(d[p]); } ans.Clear(); foreach (var y in ans2) ans.Add(y); ans2.Clear(); } ans.Sort(); Console.WriteLine(ans.Count()); Console.WriteLine(string.Join(" ",ans)); } }