#include #include using namespace std; using namespace atcoder; using ll = long long; using ld = long double; using mint = modint998244353; istream& operator>> (istream& is, mint& x) { long long _x; is >> _x; x = _x; return is; } ostream& operator<< (ostream& os, const mint& x) { return os << x.val(); } template ostream& operator<< (ostream& os, const pair& x) { return os << "{" << x.first << ", " << x.second << "}"; } #define int ll #define OVERLOAD_REP(_1, _2, _3, name, ...) name #define REP2(i, l, r) for (int i = (int)(l); i < (int)(r); ++i) #define REP1(i, n) REP2(i, 0, n) #define rep(...) OVERLOAD_REP(__VA_ARGS__, REP2, REP1)(__VA_ARGS__) #define RREP2(i, r, l) for (int i = (int)(r)-1; i >= (int)(l); --i) #define RREP1(i, n) RREP2(i, n, 0) #define rrep(...) OVERLOAD_REP(__VA_ARGS__, RREP2, RREP1)(__VA_ARGS__) #define all(x) begin(x), end(x) #define rall(x) rbegin(x), rend(x) #define pb push_back #define mp make_pair #define mt make_tuple const int INF = 4e18; const int MOD = 998244353; const int MOD1 = 1e9 + 7; template inline bool chmax(T &a, T b) { return a < b ? a = b, 1 : 0; } template inline bool chmin(T &a, T b) { return a > b ? a = b, 1 : 0; } template T pow(T a, T b, T m) { return b ? b&1 ? a*pow(a, b^1, m)%m : pow(a*a%m, b>>1, m)%m : 1; } template T pow(T a, T b) { return b ? b&1 ? pow(a, b^1)*a : pow(a*a, b>>1) : 1; } template inline void input(T&... a) { ((cin >> a), ...); } template inline void print(const T& a, const U&... b) { cout << a; ((cout << " " << b), ...); } template inline void println(const T& a, const U&... b) { print(a, b...); cout << endl; } inline void println() { cout << endl; } template inline void print(vector& A) { rep(i, A.size()) if (i) print("", A[i]); else print(A[i]); } template inline void println(vector& A) { print(A); cout << endl; } const int di[8] = {-1, 0, 1, 0, -1, -1, 1, 1}; const int dj[8] = {0, -1, 0, 1, -1, 1, -1, 1}; signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N, M, K; input(N, M, K); vector X(K); rep(i, K) { input(X[i]); --X[i]; } vector> G(N); rep(i, M) { int U, V; input(U, V); --U; --V; G[U].insert(V); G[V].insert(U); } vector can_go(N, vector(N, vector(N))); rep(si, N) { vector dp(N, vector(1LL << N, INF)); dp[si][1LL << si] = 0; rep(visited, 1LL << N) rep(i, N) { for (auto j : G[i]) { if ((visited >> j) & 1) continue; chmin(dp[j][visited ^ (1LL << j)], dp[i][visited] + 1); } } rep(j, N) rep(visited, 1LL << N) { if (dp[j][visited] == INF) continue; can_go[si][j][dp[j][visited]] = true; } } bool ans = false; rep(i, N) rep(d, N) { bool tmp = true; rep(k, K) tmp &= can_go[X[k]][i][d]; ans |= tmp; } println(ans ? "Yes" : "No"); }