program main
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: i,n,dd
    integer(int32), allocatable:: d(:,:)

    read*, n
    allocate(d(2,n))
    do i=1,n
        read*, d(:,i)
    end do

    do i=3,n
        if (f(d(:,i-2)) .and. f(d(:,i-1)) .and. f(d(:,i))) then
            print'(a)', "Yes"
            stop
        end if
    end do
    print'(a)', "No"
contains
    function f(a) result(ret)
        integer(int32):: a(2)
        logical:: ret
        ret = a(1) == a(2)
    end function
end program main