use proconio::input; use proconio::marker::Usize1; fn main() { input! { n : usize, m : usize, k : usize, x : [Usize1; k], edges : [(Usize1, Usize1); m] } let mut g = vec![vec![]; n]; for (u, v) in edges { g[u].push(v); g[v].push(u); } let mut dp = vec![0; k]; for (i, &x) in x.iter().enumerate() { dp[i] |= 1 << x; } let mut ok = dp.iter().fold(!0, |acc, &x| acc & x) > 0; for _ in 0..n { let mut next = vec![0; k]; for (i, &x) in x.iter().enumerate() { for j in 0..n { if dp[i] >> j & 1 == 0 { continue; } for &k in g[j].iter() { next[i] |= 1 << k; } } } dp = next; ok |= dp.iter().fold(!0, |acc, &x| acc & x) > 0; } println!("{}", if ok { "Yes" } else { "No" }) }