import itertools as iter import collections as coll import heapq as hq import bisect as bis from decimal import Decimal as dec from copy import deepcopy as dcopy import math import sys sys.setrecursionlimit(10**6) def input(): return sys.stdin.readline().rstrip() def getN(): return int(sys.stdin.readline()) def getNs(): return map(int,sys.stdin.readline().split()) def getList(): return list(map(int,sys.stdin.readline().split())) def strinps(n): return [sys.stdin.readline().rstrip() for _ in range(n)] pi = 3.141592653589793 mod = 10**9+7 MOD = 998244353 INF = math.inf dx = [1,0,-1,0]; dy = [0,1,0,-1] """ Union-Find from : https://github.com/customaddone/beginPython/blob/master/cgi-bin/library/unionfind/unionfind.py ref : https://algo-logic.info/union-find-tree/ """ class UnionFind(): #Uni = UnionFind(n) のようにする def __init__(self, n): self.n = n self.parents = [-1] * n #xの親(親がいないときは自身の番号を返す) def find(self, x): if self.parents[x] < 0: return x else: self.parents[x] = self.find(self.parents[x]) return self.parents[x] #xとyを関係付ける 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 # if x > y: # よりrootのインデックスが小さい方が親 # x, y = y, x self.parents[x] += self.parents[y] self.parents[y] = x #xとyが同じ組に属するかどうか def same(self, x, y): return self.find(x) == self.find(y) #xが属する組の大きさ def size(self, x): return -self.parents[self.find(x)] #xが属する組の全要素をリストとして取得 def members(self, x): root = self.find(x) return [i for i in range(self.n) if self.find(i) == root] #Union-Find木の根に当たる要素全てをリストとして取得 def roots(self): return [i for i, x in enumerate(self.parents) if x < 0] #Union-Find木の根とそれに属する組の全要素 def all_group_members(self): return {r: self.members(r) for r in self.roots()} """ Main Code """ n, m = getNs() s, g = [i - 1 for i in getNs()] ship = [[i - 1 for i in getNs()] for _ in [0] * m] t = getN() st = set(i - 1 for i in getNs()) uni = UnionFind(n) for a, b in ship: if(a not in st and b not in st): uni.union(a, b) if(uni.same(s, g)): print("Yes") else: print("No")