program Dice
implicit none
integer::N,n1,n2,c,i

read *,N
c=0

do i=1,N
read *,n1,n2
if ( n1 == n2 ) then
 c=c+1
else
 c=0
end if
if ( c >= 3 ) exit
end do

if ( c >= 3 ) then
 print *,"Yes"
else
 print *,"No"
end if

end program Dice
