#include #include #define chmin(x,y) (x) = min((x),(y)) #define chmax(x,y) (x) = max((x),(y)) using namespace std; using namespace atcoder; using ll = long long; const ll mod = 998244353; using mint = modint998244353; using Graph = vector>>; const vector dx = {1,0,-1,0}, dy = {0,1,0,-1}; pair song(int a, int b, int n){ for(int x = int(n/a); x >= 0; x--){ int y = n - a*x; if(y % b == 0) return(make_pair(x,y/b)); } return(make_pair(-1,-1)); } vector BFS(vector> g, int s){ int n = g.size(); vector res(n,-1); queue> q; q.emplace(s,0); res[s] = 0; while(!q.empty()){ auto[now,stp] = q.front(); q.pop(); for(int nxt = 0; nxt < n; nxt++){ if(g[now][nxt] == 1 && res[nxt] == -1){ res[nxt] = stp+1; q.emplace(nxt,stp+1); } } } return res; } int main(){ // input int N,M,K; cin >> N >> M >> K; vector X(K); for(int i = 0; i < K; i++){ cin >> X[i]; --X[i]; } // prep vector> G(N,vector(N,0)); while(M--){ int u,v; cin >> u >> v; --u; --v; G[u][v] = 1; G[v][u] = 1; } vector> D(K); for(int i = 0; i < K; i++) D[i] = BFS(G,X[i]); // solve bool can = 0; for(int x = 0; x < N; x++){ // x : destination if(D[0][x] < 0) continue; bool tmp = 1; for(int i = 1; i < K; i++){ if(D[i][x] != D[0][x]) tmp = 0; } if(tmp){ can = 1; break; } } // output cout << (can ? "Yes" : "No") << endl; }