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![0; n]; 1 << n]; for (i, &x) in x.iter().enumerate() { dp[1 << x][x] |= (1 << i); } let mut ok = false; for _ in 0..n { let mut next = vec![vec![0; n]; 1 << n]; for i in 0..1 << n { for j in 0..n { if i >> j & 1 == 0 { continue; } for &k in g[j].iter() { if i >> k & 1 == 1 { continue; } next[i | (1 << k)][k] |= dp[i][j]; } } } let mut tmp = vec![0; n]; for i in 0..1 << n { for j in 0..n { tmp[j] |= dp[i][j]; } } ok |= tmp.iter().any(|t| *t == (1 << k) - 1); dp = next; } let mut tmp = vec![0; n]; for i in 0..1 << n { for j in 0..n { tmp[j] |= dp[i][j]; } } ok |= tmp.iter().any(|t| *t == (1 << k) - 1); println!("{}", if ok { "Yes" } else { "No" }) }