#include //#include using namespace std; //using namespace atcoder; //using mint = modint1000000007; //const int mod = 1000000007; //using mint = modint998244353; //const int mod = 998244353; //const int INF = 1e9; //const long long LINF = 1e18; #define rep(i, n) for (int i = 0; i < (n); ++i) #define rep2(i,l,r)for(int i=(l);i<(r);++i) #define rrep(i, n) for (int i = (n) - 1; i >= 0; --i) #define rrep2(i,l,r)for(int i=(r) - 1;i>=(l);--i) #define all(x) (x).begin(),(x).end() #define allR(x) (x).rbegin(),(x).rend() #define P pair template inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; } template inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; } #ifdef _MSC_VER #define __builtin_popcount (int)__popcnt #define __builtin_popcountll (int)__popcnt64 inline int __builtin_ctz(unsigned int n) { unsigned long i; _BitScanForward(&i, n); return i; } inline int __builtin_ctzll(unsigned long long n) { unsigned long i; _BitScanForward64(&i, n); return i; } inline int __builtin_clz(unsigned int n) { unsigned long i; _BitScanReverse(&i, n); return i; } inline int __builtin_clzll(unsigned long long n) { unsigned long i; _BitScanReverse64(&i, n); return i; } #endif int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n, m, l; cin >> n >> m >> l; vectorx(l); rep(i, l)cin >> x[i], x[i]--; vector to(n, vector()); rep(i, m) { int a, b; cin >> a >> b; a--, b--; to[a].push_back(b); to[b].push_back(a); } // dp[i][j][k]:= iがjにいて、集合がk vector dp(l, vector(1 << n, vector(n))); rep(i, l) dp[i][1 << x[i]][x[i]] = true; rep(i, l)rep(j, n) rep(k, 1 << n) { if (!dp[i][j][k])continue; int ni = i; for (auto nj : to[j]) { if (1 & (j >> nj))continue; int nk = k + (1 << j); dp[ni][nj][nk] = true; } } vector bit(n + 1, vector(n));//turn pos rep(i, l)rep(j, n)rep(k, 1 << n) { if (!dp[i][j][k])continue; int pc = __builtin_popcount(j); bit[pc][k] |= 1 << i; } bool chk = false; rep(i, n + 1) rep(j, n) { if ((1 << l) - 1 == bit[i][j])chk = true; //cout << i << " " << j << " " << bit[i][j] << endl; } cout << (chk ? "Yes" : "No") << endl; return 0; }