#include #define For(i, a, b) for(long long i = a; i < b; i++) #define rep(i, n) For(i, 0, n) #define rFor(i, a, b) for(long long i = a; i >= b; i--) #define ALL(v) (v).begin(), (v).end() #define rALL(v) (v).rbegin(), (v).rend() using namespace std; using lint = long long; using ld = long double; int INF = 2000000000; lint LINF = 1000000000000000000; template struct Edge { int from, to; T cost; int idx; Edge() {} Edge(int to_) : to(to_) {} Edge(int to_, T cost_) : to(to_), cost(cost_) {} Edge(int from_, int to_, int idx_) : from(from_), to(to_), idx(idx_) {} Edge(int from_, int to_, T cost_, int idx_) : from(from_), to(to_), cost(cost_), idx(idx_) {} }; template using Graph = vector>>; using graph = Graph; using edge = Edge; #define add emplace_back int main() { int n, m, k; cin >> n >> m >> k; vector x(k); rep(i, k) { cin >> x[i]; x[i]--; } Graph g(n); rep(_, m) { int u, v; cin >> u >> v; u--; v--; g[u].add(v); g[v].add(u); } vector>> dist(n, vector>(n)); vector done(n, false); rep(i, k) { if (done[x[i]]) { continue; } done[x[i]] = true; vector visit(n, false); auto dfs = [&](auto dfs, int v, int d) -> void { visit[v] = true; dist[x[i]][v].insert(d); for (auto e : g[v]) { int nv = e.to; if (visit[nv]) { continue; } dfs(dfs, nv, d + 1); } visit[v] = false; }; dfs(dfs, x[i], 0); } rep(goal, n) { rep(d, 18) { bool ok = true; for (int start : x) { if (!dist[start][goal].count(d)) { ok = false; break; } } if (ok) { cout << "Yes" << endl; return 0; } } } cout << "No" << endl; }