using System; using static System.Console; using System.Linq; using System.Collections.Generic; class Program { static int NN => int.Parse(ReadLine()); static int[] NList => ReadLine().Split().Select(int.Parse).ToArray(); static int[] NMi => ReadLine().Split().Select(c => int.Parse(c) - 1).ToArray(); static int[][] NMap(int n) => Enumerable.Repeat(0, n).Select(_ => NMi).ToArray(); public static void Main() { Solve(); } static void Solve() { var c = NList; var (n, m, k) = (c[0], c[1], c[2]); var x = NMi; var map = NMap(m); var tree = new List[n]; for (var i = 0; i < n; ++i) tree[i] = new List(); foreach (var edge in map) { tree[edge[0]].Add(edge[1]); tree[edge[1]].Add(edge[0]); } var dic = new HashSet[n][]; for (var i = 0; i < n; ++i) { dic[i] = new HashSet[n]; for (var j = 0; j < n; ++j) dic[i][j] = new HashSet(); } for (var i = 0; i < k; ++i) { var visited = new bool[n]; DFS(x[i], i, 0, tree, dic, visited); } for (var d = 0; d < n; ++d) { for (var i = 0; i < n; ++i) { if (dic[d][i].Count == k) { WriteLine("Yes"); return; } } } WriteLine("No"); } static void DFS(int cur, int start, int dep, List[] tree, HashSet[][] dic, bool[] visited) { visited[cur] = true; dic[dep][cur].Add(start); foreach (var next in tree[cur]) { if (visited[next]) continue; DFS(next, start, dep + 1, tree, dic, visited); } visited[cur] = false; } }