#![allow(non_snake_case, unused_must_use, unused_imports)] use std::io::{self, prelude::*}; fn main() { let (stdin, stdout) = (io::read_to_string(io::stdin()).unwrap(), io::stdout()); let (mut stdin, mut buffer) = (stdin.split_whitespace(), io::BufWriter::new(stdout.lock())); macro_rules! input { ($t: tt, $n: expr) => { (0..$n).map(|_| input!($t)).collect::>() }; (Chars) => { input! {String}.chars().collect::>() }; (Usize1) => { stdin.next().unwrap().parse::().unwrap() - 1 }; ($t: ty) => { stdin.next().unwrap().parse::<$t>().unwrap() }; } let N = input!(usize); let M = input!(usize); let K = input!(usize); let X = input!(Usize1, K); let edges = (0..M) .map(|_| (input!(Usize1), input!(Usize1))) .collect::>(); let mut graph = vec![vec![]; N]; for (u, v) in edges { graph[u].push(v); graph[v].push(u); } let mut dp = vec![vec![vec![vec![false; 1 << N]; N]; N + 1]; K]; for i in 0..K { dp[i][0][X[i]][1 << X[i]] = true; } for i in 0..K { for j in 0..N { for k in 0..N { for s in 0..1 << N { if dp[i][j][k][s] { for &nxt in graph[k].iter() { if (s >> nxt) & 1 == 0 { dp[i][j + 1][nxt][s | (1 << nxt)] = true; } } } } } } } for j in 0..=N { for k in 0..N { let mut isok = true; for i in 0..K { let mut ok = false; for s in 0..1 << N { if dp[i][j][k][s] { ok = true; } } if !ok { isok = false; break; } } if isok { writeln!(buffer, "Yes"); return; } } } writeln!(buffer, "No"); }