use std::io::Read; struct Position { x: u8, y: u8, } impl Position { fn new(x: u8, y: u8) -> Position { Position { x: x, y: y, } } fn moving(&mut self, move_data: &Vec) { if move_data[0] == self.x && move_data[1] == self.y { self.x = move_data[2]; self.y = move_data[3]; } } fn equals(&self, another: &Position) -> bool { self.x == another.x && self.y == another.y } } fn solve(moves: Vec>) { let mut targets = vec![ Position::new(2 , 8) , Position::new(3 , 9) , Position::new(7 , 9) ]; moves.iter().for_each(|move_data| { targets.iter_mut().for_each(|t| t.moving(move_data)); }); let expects = vec![ Position::new(5 , 8) , Position::new(4 , 8) , Position::new(6 , 8) ]; let failed = targets.iter().zip(expects.iter()).any(|pair| !pair.0.equals(pair.1)); if failed { println!("{}", "NO"); } else { println!("{}", "YES"); } } fn main() { let mut all_data = String::new(); std::io::stdin().read_to_string(&mut all_data).ok(); let lines: Vec<&str> = all_data.trim().split('\n').map(|s| s.trim()).collect(); let n: u8 = lines.iter().next().unwrap().parse::().unwrap(); let moves: Vec> = lines.iter().skip(1).take(n as usize).map(|line| line.split_whitespace().map(|w| w.parse::().unwrap()).collect()).collect(); solve(moves); }