Problem:
Score : 200 points

Problem Statement

Tak performed the following action N times: rolling two dice.
The result of the i-th roll is D_{i,1} and D_{i,2}.

Check if doublets occurred at least three times in a row.
Specifically, check if there exists at lease one i such that D_{i,1}=D_{i,2}, D_{i+1,1}=D_{i+1,2} and D_{i+2,1}=D_{i+2,2} hold.

Constraints

3 \leq N \leq 100

1\leq D_{i,j} \leq 6

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
D_{1,1} D_{1,2}
\vdots
D_{N,1} D_{N,2}

Output

Print Yes if doublets occurred at least three times in a row. Print No otherwise.

Sample Input 1

5
1 2
6 6
4 4
3 3
3 2

Sample Output 1

Yes

From the second roll to the fourth roll, three doublets occurred in a row.

Sample Input 2

5
1 1
2 2
3 4
5 5
6 6

Sample Output 2

No

Sample Input 3

6
1 1
2 2
3 3
4 4
5 5
6 6

Sample Output 3

Yes

Solution in Rust (1.42.0) (judge verdict: Accepted)

#![allow(unused_variables, dead_code, clippy::many_single_char_names, non_upper_case_globals, unused_imports, unused_macros)]
use std::{
    collections::{BTreeMap, HashSet, HashMap, VecDeque},
    io::{stdin, stdout, StdinLock, StdoutLock, BufReader, BufWriter, prelude::*},
    mem::swap,
    str::FromStr,
};

struct Reader<'a> {
    stdin: BufReader<StdinLock<'a>>
}

#[cfg(not(debug_assertions))]
macro_rules! yubi {
    () => { unsafe { std::hint::unreachable_unchecked() } }
}

#[cfg(debug_assertions)]
macro_rules! yubi {
    () => { panic!() }
}

impl<'a> Reader<'a> {
    fn new(stdin: BufReader<StdinLock<'a/*'*/>>) -> Self {
        Self {stdin}
    }
    fn read_str(&mut self) -> String {
        let mut s = String::with_capacity(100);
        self.stdin.read_line(&mut s).unwrap();

        if s.ends_with('\n') { s.pop(); if s.ends_with('\r') { s.pop(); } }
        s
    }
    fn read_int<T: FromStr>(&mut self) -> T {
        match self.read_str().parse::<T>() {
            Ok(n) => n,
            _ => yubi!()
        }
    }
    fn read_vec(&mut self) -> Vec<String> {
        let t = self.read_str();
        t.split(' ').map(|x| x.to_owned()).collect()
    }
    fn read_vec_int<T: FromStr>(&mut self) -> Vec<T> {
        let t = self.read_str();
        t.split(' ').map(|x| match x.parse::<T>() {Ok(n) => n, _ => yubi!()}).collect()
    }
}

macro_rules! pipe_read {
    ($r: expr, str, $($x: ident),+) => {
        let t = $r.read_str();
        let mut it = t.split(' ');
        $($x = it.next().unwrap();)+
    };
    ($r: expr, $t: ty, $($x: ident),+) => {
        let t = $r.read_str();
        let mut it = t.split(' ').map(|x| x.parse::<$t>().unwrap());
        $($x = it.next().unwrap();)+
    }
}

macro_rules! pipe {
    ($r: expr, str, $($x: ident),+) => {
        pipe_read!($r, str, $($x),+);
    };
    (declare $r: expr, str, $($x: ident),+) => {
        $(let $x: &str;)+
        pipe_read!($r, str, $($x),+);
    };
    ($r: expr, $t: ty, $($x: ident),+) => {
        pipe_read!($r, $t, $($x),+);
    };
    (declare $r: expr, $t: ty, $($x: ident),+) => {
        $(let $x: $t;)+
        pipe_read!($r, $t, $($x),+);
    };
}

const M: usize = 1_000_000;

fn main() {
    let stdin = stdin();
    let stdout = stdout();
    
    solve(&mut Reader::new(BufReader::with_capacity(M, stdin.lock())), &mut BufWriter::with_capacity(M, stdout.lock()));
}

fn solve(r: &mut Reader, w: &mut BufWriter<StdoutLock>) {
    let mut count = 0;
    for _ in 0..r.read_int() {
        pipe!(declare r, u8, a, b);

        if a == b {
            count += 1;
        } else {
            count = 0;
        }

        if count > 2 {
            writeln!(w, "Yes").unwrap();
            return;
        }
    }
    writeln!(w, "No").unwrap();
}