#![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![false; N]; N + 1]; K]; for i in 0..K { dp[i][0][X[i]] = true; } for i in 0..K { for j in 0..N { for k in 0..N { if dp[i][j][k] { for &l in graph[k].iter() { dp[i][j + 1][l] = true; } } } } } for i in 0..=N { for j in 0..N { let mut isok = true; for k in 0..K { if !dp[k][i][j] { isok = false; } } if isok { writeln!(buffer, "Yes"); return; } } } writeln!(buffer, "No"); }