use std::collections::{HashSet, HashMap}; fn main() { let mut nm = String::new(); std::io::stdin().read_line(&mut nm).ok(); let nm: Vec = nm.trim().split_whitespace().map(|s| s.parse().unwrap()).collect(); let n = nm[0]; let m = nm[1]; let mut paths = vec![vec![]; n]; for _ in 0..m { let mut temp = String::new(); std::io::stdin().read_line(&mut temp).ok(); let temp: Vec = temp.trim().split_whitespace().map(|s| s.parse().unwrap()).collect(); let a = temp[0]-1; let b = temp[1]-1; paths[a].push(b); paths[b].push(a); } let mut used = HashMap::new(); for &u in paths[0].iter() { for &v in paths[u].iter() { if v > 0 { used.entry(v).or_insert(vec![]).push(u); } } } for (&u, pu) in used.iter() { for &v in paths[u].iter() { if let Some(vv) = used.get(&v) { if vv.len() > 1 || pu.len() > 1 || pu[0] != vv[0] { println!("YES"); return; } } } } println!("NO"); }