from collections import deque def bfs(s): dq = deque() dq.append([s, 0]) high = [10**9 for _ in range(N)] high[s] = 0 while len(dq) != 0: p, h = dq.popleft() for e in edge[p]: if high[e] == 10**9: dq.append([e, h + 1]) high[e] = h + 1 return high from collections import defaultdict class UnionFind(): def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): way=[] while True: if self.parents[x] < 0: break else: way.append(x) x=self.parents[x] for w in way: self.parents[w]=x return x def union(self, x, y): x = self.find(x) y = self.find(y) if x == y: return if self.parents[x] > self.parents[y]: x, y = y, x self.parents[x] += self.parents[y] self.parents[y] = x def size(self, x): return -self.parents[self.find(x)] def same(self, x, y): return self.find(x) == self.find(y) def members(self, x): root = self.find(x) return [i for i in range(self.n) if self.find(i) == root] def roots(self): return [i for i, x in enumerate(self.parents) if x < 0] def group_count(self): return len(self.roots()) def all_group_members(self): group_members = defaultdict(list) for member in range(self.n): group_members[self.find(member)].append(member) return group_members def __str__(self): return '\n'.join(f'{r}: {m}' for r, m in self.all_group_members().items()) N,M,K=map(int,input().split()) X=list(map(int,input().split())) edge=[[] for _ in range(N)] uf=UnionFind(N) for _ in range(M): u,v=map(int,input().split()) edge[u-1].append(v-1) edge[v-1].append(u-1) uf.union(u-1,v-1) for i in range(K): if not uf.same(X[i]-1,X[0]-1): print('No') exit(0) #連結か? dist=[b%2 for b in bfs(0)] for i in range(N): if uf.same(i,X[0]-1): for e in edge[i]: if dist[i]==dist[e]: assert False print('Yes') exit(0) Set=set() for i in range(K): Set.add(dist[X[i]-1]) if len(Set)==1: print('Yes') else: print('No')