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 (Python):
n = int(input())
l = 0
res = 0
for _ in range(n):
    a,b = map(int,input().split())
    if a == b:
        l += 1
        res = max(l, res)
    else:
        l = 0
print('Yes' if res>=3 else 'No')

Solution (Python):
d = int(input())
l = []
c = 0
flag = False
for i in range(d):
  a,b = list(map(int,input().split()))
  l.append([a,b])
for i in range(d):
  if l[i][0] == l[i][1]:
    c += 1
    if c >= 3:
      flag = True
  else:
    c = 0
if flag == True:
  print("Yes")
else:
  print("No")

Solution (Python):
N = int(input())
D = [[0 for j in range(2)] for i in range(N)]
c, t = 0, 0

for i in range(N):
    D[i][0], D[i][1] = map(int, input().split())
    if D[i][0] == D[i][1]:
        c += 1
    else:
        c = 0
    if c == 3:
        t = 1
if t == 1:
    print('Yes')
else:
    print('No')

Solution (Python):
N = int(input())
count = 0
for i in range(N):
    D1, D2 = map(int, input().split())    
    if D1==D2:
        count += 1
    else:
        count = 0
    if count == 3:
        print('Yes')
        exit()
print('No')

Solution (Python):
n = int(input())

duplas = 0
sim = 0
for i in range(n):
    a,b = map(int,input().split())

    if a==b:
        duplas += 1
    else:
        duplas = 0
    
    if duplas >= 3:
        sim = 1
        break

if sim:
    print("Yes")
else:
    print("No")

Solution (Python):
N=int(input())
D=[input()for i in range(N)]
count=0
max_count=0
for i in range(N):
    if D[i].split()[0]==D[i].split()[1]:
        count+=1
        if count>max_count:
            max_count=count
    else:
        count=0
if max_count>=3:
    print("Yes")
else:
    print("No")

Solution (Python):
N = int(input())
l = [list(map(int, input().split())) for l in range(N)]
for a in range(N-2):
    m = l[a]
    n = l[a+1]
    o = l[a+2]
    z = 0
    if m[0] == m[1]:
        if n[0] == n[1]:
            if o[0] == o[1]:
                z = z+1
                break;
            else:
                pass
        else:
            pass
    else:
        pass
if z == 0:
    print("No")
else:
    print("Yes")

Solution (Python):
N = int(input())

flag = False

d1 = [0]*N
d2 = [0]*N
for i in range(N):
  d1[i], d2[i] = input().split()
  
for k in range(N-2):
  if ((d1[k])==(d2[k]))and((d1[k+1])==(d2[k+1]))and((d1[k+2])==(d2[k+2])):
    flag = True
    break
    
if flag:
  print('Yes')
else:
  print('No')

Solution (Python):
t = int(input())
con = []
for i in range(t):
    a, b = map(int, input().split())
    if a==b:
        con.append(1)
    else:
        con.append(0)
    ans =0
a = []
for i in con:
    if i ==1:
        ans += 1
        a.append(ans)
    else:
        ans = 0
        a.append(ans)
if max(a) >= 3:
    print("Yes")
else:
    print("No")

Solution (Python):
N = int(input())
D = [list(map(int, input().split())) for _ in range(N)]

A = list(0 for _ in range(N))

ans = "No"

for i in range(N):
    if D[i][0] == D[i][1]:
        A[i] = 1

for i in range(N - 2):
    if A[i] == 1 and A[i+1] == 1 and A[i+2] == 1:
        ans = "Yes"


print(ans)

Solution (Python):
N=int(input())
sum=0
name=[]
for _ in range(N):
    a,b=map(int,input().split())
    if(a==b):
        sum+=1
        if(sum==3):
            name.append("Yes")
    else:
        sum=0
    
if len(name)==0:
    print("No")
else:
    print("Yes")

Solution (Python):
loop = int(input())
streak = 0
verify = False
for i in range(loop):
    diceArr = input().split()
    if diceArr[0] == diceArr[1]:
        streak+=1
        if streak==3:
            verify = True
    else:
        streak=0
if verify:
    print('Yes')
else:
    print('No')

Solution (Python):
n=int(input())
count=0
for i in range(n):
  a,b=map(int,input().split())
  if a==b:
    count+=1
    if count==3:
      print("Yes")
      exit()
  else:
    count=0
print("No")

Solution (Python):
import sys
def input():
    return sys.stdin.readline()[:-1]


def main():
    n = int(input())
    d1 = [0] * n
    d2 = [0] * n
    c = [0] * n 
    for i in range(n):
        d1[i], d2[i] = map(int, input().split())
        if d1[i] == d2[i]:
            c[i] = 1
    ans = 0
    for i in range(n - 2):
        if c[i] == 1 and c[i + 1] == 1 and c[i + 2] == 1:
            ans += 1
    if ans != 0:
        print("Yes")
    else:
        print("No")
    

    
if __name__ == "__main__":
    main()

Solution (Python):
n = input()

zorome_count = 0
max_zorome_count = 0

for i in range(int(n)):
  a,b = input().split(" ")
  if a == b:
    zorome_count += 1
  else:
    if zorome_count > max_zorome_count:
      max_zorome_count = zorome_count
    zorome_count = 0

if zorome_count > max_zorome_count:
  max_zorome_count = zorome_count

if max_zorome_count >= 3:
  print("Yes")
else:
  print("No")

Solution (Python):
import sys

n = int(input())

cnt = 0
for i in range(n):
    d1, d2 = input().split()
    if d1 == d2:
        cnt += 1
    else:
        cnt = 0
    if cnt == 3:
        print('Yes')
        sys.exit()
print('No')

Solution (Python):


N = int(input())
A = []

for i in range(N):
    D,H = map(int,input().split())

    if D == H:
        A.append(i)


cnt = 0
if len(A) <= 2:
    cnt = 0
    

else:
    for j in range(len(A)-2):
        if A[j]+1 == A[j+1] and A[j+1]+1 == A[j+2]:
            
            cnt = 1
            break



            
if cnt == 1:
    print("Yes")

else:
    print("No")

Solution (Python):
n = int(input())
cnt = [False]*n

for i in range(n):
    x,y = map(int, input().split())
    cnt[i] = x == y

ans = 'No'

for i in range(n-2):
    if cnt[i] and cnt[i+1] and cnt[i+2]:
        ans = 'Yes'

print(ans)

Solution (Python):
n=int(input())
ans=0
D=[]
A=[]
for i in range(n):
  a,b=map(int, input().split())
  D.append([a,b])


for i in range(len(D)):
  if D[i][0]==D[i][1]:
    ans +=1
  else:
    if ans>0:
      ans = 0
  A.append(ans)
  
if max(A) >= 3:
  print("Yes")
  
else:
  print("No")

Solution (Python):
in_n = input().split()
n = int(in_n[0])
in_l = []
in_r = []
for i in range(0,n):
    in_n = input().split()
    in_l.append(int(in_n[0]))
    in_r.append(int(in_n[1]))
l = 0
max_n =0
for i in range(0,n):
    if in_l[i] == in_r[i]:
        l = l +1
    else:
        l = 0
    if l > max_n:
        max_n = l
if max_n >=3:
    print("Yes")
else:
    print("No")

Solution (Python):

import sys
def solve(N: int, D: "List[List[int]]"):
    count = 0
    flag = True
    for value in list(map(lambda k: k[0] == k[1], D)):
        if value:
            count += 1
        elif count < 3:
            count = 0
    ans = "Yes" if count >= 3 else "No"
    print(ans)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    D = [[int(next(tokens)) for _ in range(2)] for _ in range(N)]  
    solve(N, D)

if __name__ == '__main__':
    main()

Solution (Python):
import sys
N = int(input())
ans = 0
for i in range(N):
  D1, D2 = [int(x) for x in input().split()]
  if(D1==D2):
    ans += 1
  else:
    ans = 0
  if(ans==3):
    print('Yes')
    sys.exit()
print('No')

Solution (Python):
def is_same(nums) -> bool:
    return nums[0] == nums[1]


def zorome(source) -> str:
    for i, nums in enumerate(source):
        if i >= len(source) - 2:
            return 'No'
        if is_same(source[i]) and is_same(source[i + 1]) and is_same(source[i + 2]):
            return 'Yes'


def main():
    count = int(input())
    nums = []
    for i in range(count):
        num1, num2 = map(int, input().split())
        nums.append((num1, num2))
    print(zorome(nums))


if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
count = 0
for i in range(n):
    s=input()
    if s[0] == s[2]:
        count += 1
    else:
        count = 0

    if count == 3:
        print('Yes')
        exit()
print('No')

Solution (Python):
n = int(input())

count = 0
for i in range(n):
    a, b = map(int, input().split())


    if count == 3:
        continue
    else:
        if a == b:
            count+=1
        else:
            count = 0



if count == 3:
    print('Yes')
else:
    print('No')

Solution (Python):
n=int(input())
lst1=[]
lst2=[]
count=0
for _ in range(n):
    m,k=[int(x) for x in input().split()]
    lst1.append(m)
    lst2.append(k)
for i in range(n-2):
    if(lst1[i]==lst2[i] and lst1[i+1]==lst2[i+1] and lst1[i+2]==lst2[i+2]):
        count=3
        break
if(count==3):
    print('Yes')
else:
    print('No')

Solution (Python):
t=int(input())
ct=0
ct1=0
for i in range(0,t):
  a,b=map(int,input().split())
  if(a==b):
    ct+=1
  else:
    ct=0
  if(ct==3):
    ct1+=1
if(ct1==0):
  print("No")
else:
  print("Yes")

Solution (Python):
from sys import stdin

N = int(input())
ct = 0
ans = 'No'
for _ in range(N):
    d1, d2 = map(int, stdin.readline().split())
    if d1 == d2:
        ct += 1
        if ct == 3:
            ans = 'Yes'
    else:
        ct = 0

print(ans)

Solution (Python):
N, *AB = map(int, open(0).read().split())
AB = list(zip(*[iter(AB)] * 2))

for (a, b), (c, d), (e, f) in zip(AB, AB[1:], AB[2:]):
    if a == b and c == d and e == f:
        print("Yes")
        quit()

print("No")

Solution (Python):
n = int(input())
ilis =[]
check = 0
for _ in range(n):
    d1, d2 = map(int, input().split())
    if d1 == d2:
        ilis.append(True)
    else:
        ilis.append(False)

for i in range(n-2):
    if ilis[i] == True and ilis[i+1] == True and ilis[i+2] == True:
        print("Yes")
        check = 1
        break
    else:
        pass
if check == 0:
    print("No")

Solution (Python):
n = int(input())
d = []
for i in range(n):
    d.append(list(map(int,input().split())))
row = []
for i in range(n):
    if d[i][0]==d[i][1]:
        row.append(True)
    else:
        row.append(False)
res = False
for i in range(n-2):
    if all(row[i:i+3]):
        res = True
if res:
    print('Yes')
else:
    print('No')

Solution (Python):
n=int(input())
xy = [map(int, input().split()) for _ in range(n)]
x, y = [list(i) for i in zip(*xy)]
ans='No'
for i in range(n-2):
  if x[i]==y[i] and x[i+1]==y[i+1] and x[i+2]==y[i+2]:
    ans='Yes'
print(ans)

Solution (Python):
N = int(input())
Dl = []
for i in range(N):
  D = list(map(int, input().split()))
  Dl.append(D)
cn = 0
df = False
for i in range(len(Dl)):
  D = Dl[i]
  D0 = D[0]
  D1 = D[1]
  if D0 == D1:    
    cn += 1
  else:
    cn = 0
  if cn == 3:
    df = True
    break
if df == True:
  print('Yes')
else:
  print('No')

Solution (Python):
N = int(input())
D1 =[]
D2 =[]
for i in range(N):
    a,b = map(int,input().split())
    D1.append(a)
    D2.append(b) 
ans = "No"
for i in range(N-2):
    if D1[i]==D2[i]:
        if D1[i+1]==D2[i+1]:
            if D1[i+2]==D2[i+2]:
                ans ="Yes"
print(ans)

Solution (Python):


N = int(input())
D = [list(map(int, input().split())) for _ in range(N)]

cnt = 0
flag = False
for d in D:
    if d[0] == d[1]:
        cnt += 1
    else:
        cnt = 0

    if cnt >= 3:
        flag = True
        break

if flag:
    print('Yes')
else:
    print('No')

Solution (Python):
N=int(input())
d1=[0]*N
d2=[0]*N
for i in range(N):
    d1[i],d2[i]=list(map(int,input().split()))
counter=0
for i in range(N-2):
    if d1[i]==d2[i] and d1[i+1]==d2[i+1] and d1[i+2]==d2[i+2]:
        counter=1
if counter==1:
    print('Yes')
else:
    print('No')

Solution (Python):
n = int(input())
xy = [map(int, input().split()) for _ in range(n)]
x, y = [list(i) for i in zip(*xy)]
count = 0
for k in range(n-2):
    if x[k] == y[k] and x[k+1] == y[k+1] and x[k+2] == y[k+2]:
        count += 1
if count >= 1:
    print('Yes')
else:
    print('No')

Solution (Python):
n = int(input())

affilé = 0
ok = 0


for i in range(n):
  d1, d2 = [int(k) for k in input().split()]
  if d1 == d2:
    affilé += 1
  elif d1 != d2:
    affilé = 0
  

  if affilé == 3:
    ok = 1

if ok == 0:
  print('No')
else:
  print('Yes')

Solution (Python):
N = int(input())                                                                                              
count = 0    
result = 'No'    
dice_list = []    
    
for i in range(N):    
    dice_list.append(list(map(int, input().split())))    
    
for i in range(N):    
    if dice_list[i][0] == dice_list[i][1]:    
        count += 1    
        if count >= 3:    
            break    
    else:    
        count = 0    
    
if count >= 3:    
    result = 'Yes'    
    
print(result)

Solution (Python):
N = int(input())
val = 0
def mojicheck(a,b):
    if a==b:
        return 1
    else:
        return 0
flag = 0
for i in range(N):
    d1,d2 = map(int,input().split())
    flag = mojicheck(d1,d2)

    if flag == 0:
        val = 0
    elif flag == 1:
        val += 1
    if val ==3:
        break
if val >=3:
    print('Yes')
else:
    print('No')

Solution (Python):
n = int(input())
w = 0
j = 0
for i in range(n):
    x, y = map(int,input().split(' '))
    if x == y:
        j += 1
        if j >= 3:
            w = 1
    else:
        j = 0
if w == 1:
    print('Yes')
else:
    print('No')

Solution (Python):
import time
from math import ceil
from collections import defaultdict, deque


def A(s):
  if s[-1] == 's':
    return s + 'es'
  return s + 's'


def B(n, d):
  for i in range(n - 2):
    if (d[i][0] == d[i][1] and d[i + 1][0] == d[i + 1][1] and
        d[i + 2][0] == d[i + 2][1]):
      return 'Yes'
  return 'No'


def main():
  n = int(input())
  d = [list(map(int, input().split())) for i in range(n)]
  print(B(n, d))


if __name__ == '__main__':
  main()

Solution (Python):
'''
    Auther: ghoshashis545 Ashis Ghosh
    College: jalpaiguri Govt Enggineering College

'''
from os import path
import sys
from heapq import heappush,heappop
from functools import cmp_to_key as ctk
from collections import deque,defaultdict as dd 
from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right
from itertools import permutations
from datetime import datetime
from math import ceil,sqrt,log,gcd
def ii():return int(input())
def si():return input().rstrip()
def mi():return map(int,input().split())
def li():return list(mi())
abc='abcdefghijklmnopqrstuvwxyz'
mod=1000000007

inf = float("inf")
vow=['a','e','i','o','u']
dx,dy=[-1,1,0,0],[0,0,1,-1]

def bo(i):
    return ord(i)-ord('a')

def ceil(a,b):
    return (a+b-1)//b
file=1

def f():
    sys.stdout.flush()





def solve():

    
   
        
    n = ii()
    a =  []
    for i in range(n):
        a.append(li())

    for i in range(n-2):
        if a[i][0]==a[i][1] and a[i+1][0]==a[i+1][1] and a[i+2][0]==a[i+2][1]:
            print('Yes')
            exit(0)
    print('No')










        
if __name__ =="__main__":

   
    if path.exists('input.txt'):
        sys.stdin=open('input.txt', 'r')
        sys.stdout=open('output.txt','w')
    else:
        input=sys.stdin.readline
    solve()

Solution (Python):
n = int(input())
d = []
for i in range(n):
    x = list(map(int, input().split()))
    d.append(x)

d2 = []
ans = "No"

for i in range(n):
    if d[i][0] == d[i][1]:
        d2.append(1)
    else:
        d2.append(0)

for i in range(0, n-2):
    if d2[i] == 1 and d2[i+1] == 1 and d2[i+2] == 1:
        ans = "Yes"
        break

print(ans)

Solution (Python):

N = int(input())

D_list = []
for _ in range(N):
    D_list.append(list(map(int,input().split())))

lenD = 0
zorome = 0
for x,y in D_list:
    if x == y:
        zorome += 1
        if zorome == 3:
            print("Yes")
            break
        else:
            pass
    else:
        zorome = 0
    lenD += 1
    if lenD >= N:
        print("No")
        break

Solution (Python):
if __name__ == "__main__":

    n = int(input())

    d1 = []
    d2 = []
    flag = 0

    for i in range(n):
        a,b = (int(x) for x in input().split())
        
        
        d1.append(a)
        d2.append(b)

        if i >= 2:
            if d1[i-2] == d2[i-2] and \
               d1[i-1] == d2[i-1] and \
               d1[i] == d2[i] :
                  flag = 1

    if 0 == flag:
        print("No")
    else:
        print("Yes")

Solution (Python):
n = int(input())
d1 = []
d2 = []
while n:
    a, b = map(int, input().split())
    d1.append(a)
    d2.append(b)
    n-=1
cnt = 0
flag = 0
for i in range(len(d1)):
    if d1[i]==d2[i]:
        cnt+=1
    else:
        cnt=0
    if cnt==3:
        flag = True
        print('Yes')
        break
if not flag:
    print('No')

Solution (Python):
_counter = 0
_max = 0
_throw = int(input())

for _i in range(_throw):
  _numbers = list(map(int, input().split(" ")))
  if _numbers[0] == _numbers[1]:
    _counter += 1
    if _counter > _max:
      _max = _counter
  else:
    _counter = 0

if _max >= 3:
  print("Yes")
else:
  print("No")

Solution (Python):

N = int(input())
count = 0
flag = 0
for i in range(N):
  x = list(map(int,input().split()))
  if x[0] == x[1]:
    count += 1
    if count >= 3:
      flag = 1
  else:
    count = 0

if flag:
  print('Yes')
else:
  print('No')

Solution (Python):
n = int(input())
ans = False
zoro = 0
for _ in range(n):
    one, two = map(int,input().split())
    if one == two:
        zoro += 1
        if zoro == 3:
            ans = True
            break
    else:
        zoro = 0
        
if ans == True:
    print("Yes")
else:
    print("No")

Solution (Python):
N = int(input())
count = 0

for i in range(N):
    D1, D2 = map(int, input().split())
    if count >= 3:
        break
    if D1 == D2:
        count += 1
    elif D1 != D2:
        count = 0

if count >= 3:
    print('Yes')
else:
    print('No')

Solution (Python):
N = int(input())
streak = 0

C = []

for i in range (0, N):
    A, B = map(int, input().split())
    C.append([A,B])

for i in range (0, N):
    if C[i][0] == C[i][1]:
        streak+=1
    else:
        streak = 0
    if streak > 2:
        print('Yes')
        exit()

print('No')

Solution (Python):
N = int(input())

flag = 0
ans = 0

for i in range(N):
    a,b = map(int,input().split())
    if a == b:
        flag += 1
        if flag == 3:
            ans += 1
    else:
        flag = 0
if ans >= 1:
    print("Yes")
else:
    print("No")

Solution (Python):
def dice(N):
    for i in range(len(N)-2):
        if N[i][0]==N[i][1] and N[i+1][0]==N[i+1][1] and N[i+2][0]==N[i+2][1]:
            return "Yes"
    return "No"

Number=int(input())
N=[]
for i in range(Number):
    x,y=input().split()
    N.append([int(x), int(y)])
print(dice(N))

Solution (Python):
N = int(input())
k1= []
k2= []
count=0
for i in range(N):
    n1,n2= map(int,input().split())
    k1.append(n1)
    k2.append(n2)
for j in range(N-2):
    if k1[j] == k2[j] and k1[j+1] == k2[j+1] and k1[j+2] == k2[j+2]:
        count +=1
if count != 0 :
    print("Yes")
else:
    print("No")

Solution (Python):
import numpy as np
import math
def permutations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r))

def A():
    xlist  = list(map(int,input().split()))
    xnp = np.array(xlist)
    xplace = np.where(xnp==0)
    print(str(xplace[0][0]+1))
def B030():
    import math
    n,m = map(int,input().split())
    n = n%12

    longs = 360*m/60
    shorts = 360*n/12+m/60*30

    print("%2.4f" % min(abs(longs-shorts),360-abs(longs-shorts)))

def AGC015_A():
    n,a,b = map(int,input().split())

    if n == 1:
        if a!=b:
            print("0")
            return
        else:
            print("1")
            return
    else:
        print(permutations_count(b-a+1,n-2))

def ABC107_A():
    n,i=map(int,input().split())
    print(n-i+1)

def ABC172_A():
    import math
    a = int(input())
    print(a+pow(a,2)+pow(a,3))

def ABC172_B():
    s = input()
    t = input()

    counter=0
    for i in range(len(s)):
        if s[i] != t[i]:
            counter += 1
    if counter == len(s):
        print(counter)
    else:
        print(counter)

def ABC172_C():
    import sys
    sys.setrecursionlimit(4100000)

    n,m,k = map(int,input().split())
    a = list(map(int,input().split()))
    b = list(map(int,input().split()))

    if k < a[0] or k < b[0]:
        print(0)
        return

    minamo = []
    def saiki(i,j,sum,mx):
        if sum >= k:
            mx = min(i+j,mx)
            return mx

        if i+j >= mx:
            return mx

        if i+1 <= n:
            mx = saiki(i+1,j,sum+a[i],mx)
        if j+1 <= m:
            mx = saiki(i,j+1,sum+b[j],mx)

        return mx

    mls = saiki(0,0,0,pow(10,5))
    print(mls)



def ABC172_Dd():
    def make_divisors(n):
        lower_divisors , upper_divisors = [], []
        i = 1
        while i*i <= n:
            if n % i == 0:
                lower_divisors.append(i)
                if i != n // i:
                    upper_divisors.append(n//i)
            i += 1
        return lower_divisors + upper_divisors[::-1]

    n = int(input())
    sum = 0
    for i in range(1,n+1):
        sum += i * len(make_divisors(i))
    print(sum)

def ABC172_D():
    def num_divisors_table(n):
        table = [0] * (n + 1)

        for i in range(1, n + 1):
            for j in range(i, n + 1, i):
                table[j] += 1

        return table

    a = num_divisors_table(4)
    print(a)

def ABC046_B():
    import numpy as np
    n,k = map(int,input().split())
    print(n,k)

    for i in range(n):
        ans = k*np.power(k-1,n-1)

    print(ans)

def CODE_festival_2016_A():
    import numpy as np
    N = int(input())
    a = np.array(list(map(int,input().split())))

    ans = 0
    for i in range(N):
        if i == a[a[i]-1]-1:
            ans += 1

    print(int(ans) if ans%2==1 else int(ans/2))

def abc054_b():
    import pandas as pd
    N,M = map(int,input().split())
    a = [input() for i in range(N)]
    b = [input() for i in range(M)]

    ans1=0
    a_df = pd.DataFrame(a)
    for m in range(M):
        for n in range(N):
            if a_df.iloc[:,0].str.contains(b[m])[n]:
                ans1+=1

    a_dfT = pd.DataFrame(a).T
    b = pd.DataFrame(b).T.to_numpy().tolist()[0]

    ans2=0
    for m in range(len(a_dfT)):
        for n in range(len(b)):
            if a_dfT.iloc[:,0].str.contains(b[n])[m]:
                ans2+=1

    if ans1==ans2:
        print("Yes" if ans1==len(b) else "No")
    else:
        print("No")

def test():
    import pandas as pd
    import numpy as np
    a = ["


    ans1=0
    a_df = pd.DataFrame(a)
    for m in range(M):
        for n in range(N):
            if a_df.iloc[:,0].str.contains(b[m])[n]:
                print()
                ans1+=1

    a_dfT = pd.DataFrame(a).T
    b = pd.DataFrame(b).T.to_numpy().tolist()[0]

    ans2=0
    for m in range(len(a_dfT)):
        for n in range(len(b)):
            if a_dfT.iloc[:,0].str.contains(b[n])[m]:
                ans2+=1

    if ans1==ans2:
        print("Yes" if ans1==len(b) else "No")
    else:
        print("No")

'''
6 4

.


.


.

.
'''

def abc002_D():
    N,M = map(int,input().split())
    xy = [];people=[[] for i in range(N)]
    print(people)
    for i in range(M):
        xy = list(map(int,input().split()))

        people[xy[0]-1].append(xy[1])
        people[xy[1]-1].append(xy[0])

    print(people)

    Gatcha = 0
    for Order in range(N):
        for PeopleIndex in people[Order]:
            if Order in people[PeopleIndex-1]:
                Gatcha+=1
        if len(people(Order))==Gatcha:
            pass

def abc173_a():
    N = int(input())
    
    if N%1000 ==  0:
        print(0)
    else:
        print(1000-N%1000)

def abc173_b():
    N = int(input())

    
    l = [0 for i in range(4)]

    for i in range(N):
        Inp = input()
        if Inp == "AC":
            l[0] += 1
        if Inp == "WA":
            l[1] += 1
        if Inp == "TLE":
            l[2] += 1
        if Inp== "RE":
            l[3] += 1

    print("AC x "+str(l[0]))
    print("WA x "+str(l[1]))
    print("TLE x "+str(l[2]))
    print("RE x "+str(l[3]))

def abc173_c():
    pass


def abc173_d():
    import sys
    sys.setrecursionlimit(4100000)
    N = int(input())
    a =  list(map(int,input().split()))


    a = sorted(a,reverse=True)

    Enkan = [a[0],a[1]]





    gokei = []
    def saiki(i,suma,Enkan):

        if i == N:
            gokei.append(sum(suma))
            return
        else:
            for k in range(len(Enkan)):

                if k != len(Enkan)-1:
                    suma.append(min(Enkan[k],Enkan[k+1]))
                    Enkan.insert(k,a[i])
                    saiki(i+1,suma,Enkan)
                    del Enkan[k]
                    del suma[-1]
                else:
                    suma.append(min(Enkan[-1],Enkan[0]))
                    Enkan.insert(0,a[i])
                    saiki(i+1,suma,Enkan)
                    del Enkan[0]
                    del suma[-1]

    saiki(2,[3],[a[0],a[1]])
    print(max(gokei))

def abc037_c():
    n,k = map(int,input().split())
    a = list(map(int,input().split()))

    suma = 0
    ruiseki = [0]*(n+1)

    for i in range(n):
        ruiseki[i+1] = ruiseki[i] + a[i]
    

    for i in range(n):

        suma += ruiseki[n-k+1+i] - ruiseki[i]
        
        if n-k+1+i == n:
            break
    print(suma)

def abc061_c():
    s = str(input())

    l = []
    def saiki(i,moji):
        if i == len(s)-1:
            
            l.append(sum(list(map(int,moji.split("+")))))
            return

        
        saiki(i+1,moji+"+"+s[i+1])
        
        saiki(i+1,moji+s[i+1])

    saiki(0,s[0])

    print(sum(l))

def abc104_c():
    d,g = map(int,input().split())
    plist = []; clist = []
    for i in range(d):
        Inp = list(map(int,input().split()))
        plist.append(Inp[0])
        clist.append(Inp[1])

    def saiki(i,sum):
        if sum > g:
            return

        saiki(i+1,sum+v_new)
        saiki(i+1,sum+v_new)

def agc037_a():
    import sys
    input = sys.stdin.readline

    S = input().rstrip('\n')
    left = ''
    now = ''
    ans = 0
    for i in range(len(S)):
        now += S[i]
        if left != now:
            ans += 1
            left = now
            now = ''
        
    print(ans)


def arc29_a():
    import numpy as np
    N = int(input())
    t = [int(input()) for i in range(N)]

    l = []
    plist = []
    def saiki(i,sum1,sum2):
        if i == N:
            l.append([sum1,sum2])
            return

        saiki(i+1,sum1+t[i],sum2)
        saiki(i+1,sum1,sum2+t[i])

    saiki(0,0,0)

    p = 10**4; ans = 0
    for i in range(len(l)):
        if abs(l[i][0]-l[i][1]) < p:
            p = abs(l[i][0]-l[i][1])
            ans = max(l[i][0],l[i][1])


    print(ans)

def EducationDPcontest_D():
    N, W = list(map(int,input().split()))

    w = []; v = []; weight=[]
    for i in range(N):
        INP = list(map(int,input().split()))
        w.append(INP[0])
        v.append(INP[1])

    def saiki(i,weight_sum,value_sum):
        
        if weight_sum <= W:
            print("ans",i,weight_sum,value_sum)
        else:
            return
        if i == N:
            return
        else:
            for j in range(i,N):
                saiki(i+1, weight_sum+w[j],value_sum+v[j])

    saiki(0,0,0)

def Msol_B():
    
    

    a,b,c=[7,0,5]
    K = 3

    if a==0 or b==0 or c==0:
        print("No")
        exit()

    import math

    if a > b:
        b_a = abs(math.log2(b/a))+1
        
        b *= math.pow(2,math.floor(b_a))
        if b > c:
            c_b = abs(math.log2(c/b))+1
            if math.floor(b_a)+math.floor(c_b) <= K:
                print("Yes")
            else:
                print("No")
        else:
            print("Yes")
    else:
        print("Yes")

def Msol_B_():
    import numpy as np
    
    

    a,b,c=np.array([7,2,5],dtype=np.float64)
    K = 3

    for i in range(7):
        if K==1:
            print('No')
            return
        if a > b:
            temp = 2 * b
            b = temp
            K -= 1
        else:
            break

    for i in range(7):
        if  K ==1:
            print('No')
            return
        if b > c:
            temp = 2 * c
            c = temp
            K -= 1
        else:
            print()
            break

def Msol_C():
    n,k = list(map(int,input().split()))
    a = np.array(list(map(int,input().split())),dtype=np.float64)

    for i in range(n-k):
        if np.prod(a[i:i+k]) > np.prod(a[i+1:i+1+k]):
            print('Yes')
        else:
            print("No")


def abc177_d():
    n,m = list(map(int,input().split()))

    alist = [[] for i in range(m)]
    blist = [[] for i in range(m)]
    for i in range(m):
      a,b =list(map(int,input().split()))
      alist[i] = a
      blist[i] = b

    print(alist)
    print(blist)
    
    l = [[] for i in range(n+1)] 
    for i in range(m):
      l[alist[i]].append(blist[i])
      l[blist[i]].append(alist[i])


    print(l)

def nani():
    import numpy as np
    from sklearn import preprocessing

    
    train = [1,2,3,4,5,5,6,7]
    scaler = preprocessing.MinMaxScaler().fit(train)

    
    temp = [1,2,3,4,5,5,6,7]
    temp = scaler.transform(temp)

def abc179b():
    n = int(input())
    d1list = []
    d2list = []
    cnt = 0
    for i in range(n):
        d1,d2  = list(map(int,input().split()))
        d1list.append(d1)
        d2list.append(d2)

        
        if d1 == d2:
            cnt += 1
        else:
            cnt = 0

        if cnt >2:
            print("Yes")
            return

    print("No")




















abc179b()

Solution (Python):
if __name__=="__main__":
    N = int(input())
    same = 0
    for i in range(N):
        D1, D2 = (int(x) for x in input().split())
        if D1==D2:
            same += 1
        else:
            if same>=3:
                continue
            else:
                same = 0
    if same>=3:
        print('Yes')
    else:
        print('No')

Solution (Python):
n = int(input())
ct, f = 0, 0
for i in range(n):
    d1, d2 = map(int, input().split())
    if d1 == d2:
        ct += 1
    else: ct = 0

    if ct == 3 and f == 0:
        f = 1

if f == 1:
    print('Yes')
else: print('No')

Solution (Python):
import sys

n = int(input())

d1d2 = [map(int, input().split()) for _ in range(n)]
d1, d2 = [list(i) for i in zip(*d1d2)]

cnt = 0
for i in range(n):
    if d1[i] == d2[i]:
        cnt += 1
    else:
        cnt = 0
    if cnt >= 3:
        print("Yes")
        sys.exit()

print("No")

Solution (Python):
n = int(input())
num_list = []
checkFlg = False
cnt = 0
for i in range(n):
    d1, d2 = input().split()
    if d1 == d2:
        cnt += 1
    else:
        cnt = 0
    if cnt == 3:
        print('Yes')
        checkFlg = True
        break
if not checkFlg:
    print('No')

Solution (Python):
n=int(input())
zoro=0
L=False
for i in range(n):
  p,q=map(int,input().split())
  if p==q:
    zoro+=1
    if zoro==3:
      L=True
  else:
    zoro=0
if L:
  print("Yes")
else:
  print("No")

Solution (Python):
N = int(input())
count=0
for i in range(N):
  d1, d2 = map(int,input().split())
  if d1 == d2:
    count += 1
    if count==3:
      print('Yes')
      break
  else:
    count=0

else:
  print('No')