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 paths2 = vec![vec![]; n]; for &u in paths[0].iter() { for &v in paths[u].iter() { if v > 0 { paths2[v].push(u); } } } for l1 in 1..n { for &r1 in paths[l1].iter() { for &l2 in paths2[l1].iter() { if l2 == r1 { continue; } for &r2 in paths2[r1].iter() { if r2 == l1 || r2 == l2 { continue; } println!("YES"); return; } } } } println!("NO"); }