use proconio::input; fn main() { println!("{}", if solve() { "Yes" } else { "No" }); } fn solve() -> bool { input! { (n, m): (usize, usize), ij: [(usize, usize); m], mut vv: [usize; 3], } vv.sort_unstable(); vv.dedup(); let mut graph = vec![vec![]; n]; for &(u, v) in &ij { graph[u].push(v); graph[v].push(u); } let mut stack = (0..n).map(|i| vec![i]).collect::>(); while let Some(path) = stack.pop() { let cur = *path.last().unwrap(); for &next in &graph[cur] { if path.len() >= 3 && next == path[0] { let mut nodes = path.clone(); nodes.sort_unstable(); nodes.dedup(); if nodes != vv { return true; } continue; } if path.contains(&next) { continue; } let mut next_path = path.clone(); next_path.push(next); stack.push(next_path); } } false }