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![vec![false; n]; 1 << k]; for (i, &x) in x.iter().enumerate() { dp[1 << i][x] = true; } for (i, &x) in x.iter().enumerate() { for s in 0..1 << k { dp[s | (1 << i)][x] |= dp[s][x]; } } let mut ok = false; for s in 0..1 << k { let mut t = s; while t > 0 { for i in 0..n { for (k, &u) in g[i].iter().enumerate() { if !dp[s ^ t][u] { continue; } for &v in g[i].iter().skip(k + 1) { if dp[s ^ t][u] && dp[t][v] { dp[s][i] = true; } } } } t = (t - 1) & s; } } // for i in 0..1 << k { // eprintln!("{:03b} {:?}", i, dp[i]); // } ok |= dp[(1 << k) - 1].iter().any(|&a| a); println!("{}", if ok { "Yes" } else { "No" }) }