#include using namespace std; #define rep(i, n) for(int i=0; i #include //vectorの中身を空白区切りで出力 template void printv(vector v) { for (int i = 0; i < v.size(); i++) { cout << v[i]; if (i < v.size() - 1) { cout << " "; } } cout << endl; } //vectorの中身を改行区切りで出力 template void print1(vector v) { for (auto x : v) { cout << x << endl; } } //二次元配列を出力 template void printvv(vector> vv) { for (vector v : vv) { printv(v); } } //vectorを降順にソート template void rsort(vector& v) { sort(v.begin(), v.end()); reverse(v.begin(), v.end()); } //昇順priority_queueを召喚 template struct rpriority_queue { priority_queue, greater> pq; void push(T x) { pq.push(x); } void pop() { pq.pop(); } T top() { return pq.top(); } size_t size() { return pq.size(); } bool empty() { return pq.empty(); } }; //mod mod下で逆元を算出する //高速a^n計算(mod ver.) ll power(ll a, ll n) { if (n == 0) { return 1; } else if (n % 2 == 0) { ll x = power(a, n / 2); x *= x; x %= mod; return x; } else { ll x = power(a, n - 1); x *= a; x %= mod; return x; } } //フェルマーの小定理を利用 ll modinv(ll p) { return power(p, mod - 2) % mod; } //Mexを求める struct Mex { map mp; set s; Mex(int Max) { for (int i = 0; i <= Max; i++) { s.insert(i); } } int _mex = 0; void Input(int x) { mp[x]++; s.erase(x); if (_mex == x) { _mex = *begin(s); } } void Remove(int x) { if (mp[x] == 0) { cout << "Mex ERROR!: NO VALUE WILL BE REMOVED" << endl; } mp[x]--; if (mp[x] == 0) { s.insert(x); if (*begin(s) == x) { _mex = x; } } } int mex() { return _mex; } }; //Union-Find struct UnionFind { vector par; UnionFind(int N) : par(N) { for (int i = 0; i < N; i++) { par[i] = -1; } } //root(x):xの根を求める関数 int root(int x) { if (par[x] == -1) { return x; } else { return par[x] = root(par[x]); } } //isSame(x,y):xとyが同じグループならtrueを返す関数 bool isSame(int x, int y) { if (root(x) == root(y)) { return true; } else { return false; } } //Union(x,y):xとyの根をつなげる関数 void Union(int x, int y) { int X = root(x); int Y = root(y); if (X == Y) { return; } if (X < Y) { swap(X, Y); } par[X] = Y; } }; //最大公約数(ユークリッドの互除法) ll gcd(ll a, ll b) { if (b > a) { swap(a, b); } while (a % b != 0) { ll t = a; a = b; b = t % b; } return b; } //最小公倍数(gcdを定義しておく) ll lcm(ll a, ll b) { ll g = gcd(a, b); ll x = (a / g) * b; return x; } struct SegTree { vector tree; ll n = 1; SegTree(int M) { while (n < M) { n *= 2; } vector t(n * 2, 0); swap(tree, t); } void update(ll i) { if (i > 0) { ll j = (i % 2 == 0 ? i - 1 : i + 1); tree[(i - 1) / 2] = tree[i] + tree[j]; update((i - 1) / 2); } } void add(ll r) { tree[n - 1 + r]++; update(n - 1 + r); } ll sum(ll l, ll r, ll d, ll u, ll now) { if (l >= u || r <= d) { return 0; } else if (l <= d && r >= u) { return tree[now]; } else { return sum(l, r, d, (d + u) / 2, now * 2 + 1) + sum(l, r, (d + u) / 2, u, now * 2 + 2); } } ll query(ll l, ll r) { return sum(l, r + 1, 0, n, 0); } }; int main() { int N, M, K; cin >> N >> M >> K; vector> path(N); vector start(K); rep(i, K) { int a; cin >> a; a--; start[i] = a; } rep(i, M) { int u, v; cin >> u >> v; u--; v--; path[u].push_back(v); path[v].push_back(u); } vector>>>> memo(N, vector>>>(N, vector>>(N))); vector>> rec(N, vector>(N)); vector> bin(N + 1); rep(i, N+1) { bin[i] = 1< bs = bin[s]; memo[s][s][0].insert(bs); rep(m, N) { rep(g, N) { if (!memo[s][g][m].empty()) { rec[g][m].insert(k); for (bitset<15> b : memo[s][g][m]) { for (int x : path[g]) { if (!b[x]) { //cout << "k=" << k << " s=" << s << " x=" << x << " m=" << m << endl; memo[s][x][m + 1].insert(b | bin[x]); } } } } } } } bool ok = false; rep(g, N) { rep(m, N) { if (rec[g][m].size() == K) { ok = true; } } } cout << (ok ? "Yes" : "No") << endl; }