#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); } // cnt[i][j] := 頂点 i へ j 回の移動で到達できる人の数 vector> cnt(n, vector(20)); rep(i, k) { // dp[s][v] := 通った頂点集合が s で、今 v にいることは可能か? vector> dp(1 << n, vector(n, false)); dp[1 << x[i]][x[i]] = true; rep(s, 1 << n) { rep(v, n) { for (auto e : g[v]) { int nv = e.to; if (s & (1 << nv)) { continue; } int ns = s | (1 << nv); if (dp[s][v]) { dp[ns][nv] = true; } } } } rep(s, 1 << n) { rep(v, n) { if (dp[s][v]) { cnt[v][__builtin_popcount(s) - 1] |= (1 << i); } } } } rep(i, n) { rep(j, 20) { if (cnt[i][j] == (1 << k) - 1) { cout << "Yes" << endl; return 0; } } } cout << "No" << endl; }