#if !__INCLUDE_LEVEL__ #include __FILE__ struct bll{ //第0~62bitまで対応 ll s; bll(ll s_=0): s(s_){} struct ref { bll &b; const ll msk; ref(bll &b_,ll pos):b(b_),msk(1LL<>pos)&1; } bll &on (ll l,ll r){ s|= rangemask(l,r); return *this; } bll &off (ll l,ll r){ s&=~rangemask(l,r); return *this; } bll &flip(ll l,ll r){ s^= rangemask(l,r); return *this; } static ll rangemask(ll l,ll r){ return (1LL<<(r+1))-(1LL<(s).count(); } vl idxes()const{ vl v; for(ll i=0,t=s; t; t>>=1,i++) if(t&1)v.push_back(i); return v; } }; /* bll b(s); b[3]=1; //第3bitを1に b.on(4,7).off(9,59).flip(0,3); //第4~7bitを1に、等 b.s+=10; //普通に数値として扱いたい時 //0000001000101100 b ll c=b.msb(); //0000001000000000 b.msb() ll c=b.msbit(); // ^第9bit b.msbit() ll c=b.lsb(); //0000000000000100 b.lsb() ll c=b.lsbit(); // 第2bit^ b.lsbit() ll c=b.count(); //1の数 (4個) vll idxes=b.idxes(); //1のidxのvll {2,3,5,9} */ vector iki(20,false); vector kaeri(20,false); vector Go(20,vector(20)); void dfs(const Graph &G, int u,int cost,int k) { iki[u] = true; //cout << u << " " << cost <> N >> M >> K; vl X(K);rep(i,K){ cin >> X[i]; X[i]-=1; } Graph G(N); rep(i,M){ int u,v; cin >> u >> v; u-=1; v-=1; G.add_edge(u,v); } rep(k,K){ dfs(G,X[k],0,k); } bool Ans = false; ll All = 1; rep(i,K)All*=2; All-=1; //cout << All << endl; rep(i,N){ rep(cost,N+1){ if(Go[i][cost].s==All)Ans = true; } } if(Ans) cout << "Yes" << "\n"; else cout << "No" << "\n"; } #else // tie(a, b, c) = t // repをllにしているので時間ギリギリならintに変換 #include #include using namespace std; using namespace atcoder; #define rep(i, n) for (long long int i = 0; i < n; i++) #define rrep(i, n) for (long long int i = n - 1; i >= 0; i--) #define range(i, m, n) for (long long int i = m; i < n; i++) #define fore(i, a) for (auto &i : a) #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(), v.rend() #define Sum(v) accumulate(all(v), 0LL) #define minv(v) *min_element(all(v)) #define maxv(v) *max_element(all(v)) #define fi first #define se second typedef long long ll; typedef vector vl; typedef vector > vvl; const ll INF = 1LL << 60; const ll MOD1 = 1000000007; const ll MOD2 = 998244353; template inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } ll SN(char s) { return ll(s - '0'); } ll SN(string s) { return stoll(s); } int alpN(char s) { return int(s - 'a'); } int AlpN(char s) { return int(s - 'A'); } int Nalp(int n) { return char(n + 97); } int NAlp(int n) { return char(n + 65); } using mint = modint; using mint1 = modint1000000007; using mint2 = modint998244353; using pll = pair; template ostream &operator<<(ostream &o, const vector &v) { for (int i = 0; i < (int)v.size(); i++) o << (i > 0 ? " " : "") << v[i]; return o; } // vector空白区切り出力 template ostream &operator<<(ostream &o, pair &p) { o << "(" << p.first << ", " << p.second << ")"; return o; } ostream &operator<<(ostream &os, const mint1 &N) { return os << N.val(); } // mint出力。デフォはmint1 ostream &operator<<(ostream &os, const mint2 &N) { return os << N.val(); } template bool contain(const std::string &s, const T &v) { return s.find(v) != std::string::npos; } ll max(int x, ll y) { return max((ll)x, y); } ll max(ll x, int y) { return max(x, (ll)y); } ll min(int x, ll y) { return min((ll)x, y); } ll min(ll x, int y) { return min(x, (ll)y); } template struct Edge { int from, to; T cost; int idx; Edge() = default; Edge(int from, int to, T cost = 1, int idx = -1) : from(from), to(to), cost(cost), idx(idx) {} operator int() const { return to; } }; template struct Graph { vector > > g; int es; Graph() = default; explicit Graph(int n) : g(n), es(0) {} size_t size() const { return g.size(); } void add_directed_edge(int from, int to, T cost = 1) { g[from].emplace_back(from, to, cost, es++); } void add_edge(int from, int to, T cost = 1) { g[from].emplace_back(from, to, cost, es); g[to].emplace_back(to, from, cost, es++); } void read(int M, int padding = -1, bool weighted = false, bool directed = false) { for (int i = 0; i < M; i++) { int a, b; cin >> a >> b; a += padding; b += padding; T c = T(1); if (weighted) cin >> c; if (directed) add_directed_edge(a, b, c); else add_edge(a, b, c); } } inline vector > &operator[](const int &k) { return g[k]; } inline const vector > &operator[](const int &k) const { return g[k]; } }; template using Edges = vector >; template using Matrix = vector >; // unorderd_mapの拡張…https://qiita.com/hamamu/items/4d081751b69aa3bb3557 template size_t HashCombine(const size_t seed, const T &v) { return seed ^ (std::hash()(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2)); } /* pair用 */ template struct std::hash > { size_t operator()(const std::pair &keyval) const noexcept { return HashCombine(std::hash()(keyval.first), keyval.second); } }; /* vector用 */ template struct std::hash > { size_t operator()(const std::vector &keyval) const noexcept { size_t s = 0; for (auto &&v : keyval) s = HashCombine(s, v); return s; } }; /* tuple用 */ template struct HashTupleCore { template size_t operator()(const Tuple &keyval) const noexcept { size_t s = HashTupleCore()(keyval); return HashCombine(s, std::get(keyval)); } }; template <> struct HashTupleCore<0> { template size_t operator()(const Tuple &keyval) const noexcept { return 0; } }; template struct std::hash > { size_t operator()(const tuple &keyval) const noexcept { return HashTupleCore >::value>()(keyval); } }; ll ceil(ll a, ll b) { return (a + b - 1) / b; } struct string_converter { char start = 0; char type(const char &c) const { return (islower(c) ? 'a' : isupper(c) ? 'A' : isdigit(c) ? '0' : 0); } int convert(const char &c) { if (!start) start = type(c); return c - start; } int convert(const char &c, const string &chars) { return chars.find(c); } template auto convert(const T &v) { vector ret; ret.reserve(v.size()); for (auto &&e : v) ret.emplace_back(convert(e)); return ret; } template auto convert(const T &v, const string &chars) { vector ret; ret.reserve(v.size()); for (auto &&e : v) ret.emplace_back(convert(e, chars)); return ret; } int operator()(const char &v, char s = 0) { start = s; return convert(v); } int operator()(const char &v, const string &chars) { return convert(v, chars); } template auto operator()(const T &v, char s = 0) { start = s; return convert(v); } template auto operator()(const T &v, const string &chars) { return convert(v, chars); } } toint; #endif