peterverebics/CodeNet_Python_118 huggingface dataset:
n=int(input())
zoro=0
for i in range(n):
  d1,d2=map(int,input().split())
  if d1==d2:
    zoro+=1
  else:
    zoro=0
  if zoro==3:
    print('Yes')
    exit()
print('No')
n=int(input())
c=0
for i in range(n):
	a,b=map(int, input().split())
	if a==b:
		c+=1
		if c==3:
			print("Yes")
			exit()
	else:
		c=0
print("No")
N = int(input())

result = ""

for _ in range(N):
  D1, D2 = map(int, input().split())
  if D1 == D2:
    result += "1"
  else:
    result += "0"

if "111" in result:
  print("Yes")
else:
  print("No")
n=int(input())
count=0
for i in range(n):
  me1,me2=list(map(int,input().split()))
  if me1==me2:
    count+=1
    if count==3:
      break
  else:
    count=0
if count>=3:
  print('Yes')
else:
  print('No')
N=int(input())
Di=[input() for i in range(N)]
count=0
n=0
D=[]
a=[]
A=0
for i in range(N):
    D.append(Di[i].split())

for i in range(N):
    if D[i][0]==D[i][1]:
        count+=1
    else:
        a.append(count)
        count=0
if len(a)==0:
    A=0
else:
    A=max(a)

if A>count:
    n+=A
else:
    n+=count
if n>=3:
    print("Yes")
else:
    print("No")
N = int(input())
D_list = []
for _ in range(N):
    D1, D2 = map(int, input().split())
    D_list.append([D1, D2])

sequence_doublet = 0
for D in D_list:
    if D[0] == D[1]:
        sequence_doublet += 1
    else:
        sequence_doublet = 0
    
    if sequence_doublet == 3:
        break

if sequence_doublet == 3:
    print("Yes")
else:
    print("No")
n = int(input())
z = []
y = 0
for i in range(n):
  line = input().split(" ")
  if int(line[0])==int(line[1]):
    z.append(i)

for i in range(len(z)-2):
  if z[i]==z[i+1]-1:
    if z[i+1]==z[i+2]-1:
      y += 1
if y > 0:
  print("Yes")
else:
  print("No")
n = int(input())
d1,d2 = [],[]
for _ in range(n):
    a,b = map(int,input().split())
    d1.append(a)
    d2.append(b)
check = True
for i in range(2,n):
    if d1[i-2] == d2[i-2] and d1[i-1] == d2[i-1] and d1[i] == d2[i]:
        print("Yes")
        check = False
        break
if check:
    print("No")
n = int(input())
d1, d2 = [], []
for i in range(n):
    a, b = input().split()
    d1.append(int(a))
    d2.append(int(b))

count = 0
for a, b in zip(d1, d2):
    if a == b:
        count += 1
    else:
        count = 0
    if count == 3:
        print('Yes')
        break

if count != 3:
    print('No')
N = int(input())

count = 0
for i in range(N):
  d1,d2 = map(int,input().split())
  if(d1==d2):
    count = count + 1
  else:
    count = 0
  if(count == 3):break
if(count == 3):
  print("Yes")
else:
  print("No")
Count = 0
Array = []
for i in range(int(input())):
    Dice_1, Dice_2 = map(int, input().split())
    if Dice_1 == Dice_2:
        Array.append(1)
    else:
        Array.append(0)

ans = []
j_1 = 0
for j in range(len(Array)):
    if j_1 == 1 and Array[j] == 1:
        Count = Count + 1
    else:
        Count = 0
    j_1 = Array[j]
    ans.append(Count)
if max(ans) >= 2:
    print('Yes')
else:
    print('No')
## coding: UTF-8
N = int(input())
D = [list(map(int, input().split())) for _ in range(N)]

#print(N, D)

ans = "No"
renzoku = 0

for i in range(N):
    if(D[i][0] == D[i][1]):
        renzoku += 1
        if(renzoku >= 3):
            ans = "Yes"
    else:
        renzoku = 0

print(ans)
N = int(input())
D = [input().split() for l in range(N)]

zoro = []
for i in range(N):
  if D[i][0] == D[i][1]:
    zoro.append(1)
  else:
    zoro.append(0)

cnt = []
for i in range(N-2):
  cnt.append(zoro[i]+zoro[i+1]+zoro[i+2])
  

zoro_cnt = 0
for i in range(N-2):
  if cnt[i] == 3:
    zoro_cnt += 1


if zoro_cnt >= 1:
  print("Yes")
else:
  print("No")
import sys
N = int(input())
D = []
for i in range(N):
    D.append(input().split())
cnt = 0
for i in range(N):
    if D[i][0] == D[i][1]:
        cnt += 1
        if cnt == 3:
            print("Yes")
            sys.exit()
    else:
        cnt = 0
print("No")
cnt = 0
n = int(input())
for i in range(n):
    n,m = map(int,input().split())
    if n == m:
        cnt += 1
    else:
        cnt = 0
    if cnt == 3:
        print("Yes")
        exit()
print("No")
N=int(input())
D=list()
for i in range(N):
    tmp=list(map(int,input().split()))
    D.append(tmp[0]==tmp[1])
for i in range(N-2):
    if D[i]==D[i+1]==D[i+2]==True:
        print("Yes")
        break
else:
    print("No")
n=int(input())
tmp=0
flag=0
for i in range(n):
    x,y=map(int,input().split())
    if(x==y):
        tmp+=1
    else:
        tmp=0
    if(tmp==3):
        flag=1
        break
if(flag):
    print('Yes')
else:
    print('No')
N = int(input())
l = [0]*N
for i in range(N):
    a,b = [int(x) for x in input().split()]
    if a == b:
        l[i] = 1
for i in range(1,N):
    if l[i] == 1:
        l[i] = l[i-1] + 1
    else:
        l[i] = 0
if max(l) >= 3:
    print("Yes")
else:
    print("No")
n = int(input())
D = [tuple(int(x) for x in input().split()) for _ in range(n)]
tmp = 0
for d1, d2 in D:
    if d1 == d2:
        tmp += 1
    else:
        tmp = 0
    if tmp == 3:
        print("Yes")
        exit()
print("No")
a = int(input())
b = []
c = ""
x = 0
for i in range(a):
    c = input().split()
    if c[0] == c[1]:
        x = x + 1
    else:
        x = 0
    if x >= 3:
        print("Yes")
        exit()
if x <= 3:
    print("No")
N=int(input())
D=[list(map(int,input().split())) for i in range(N)]
tf=0
for j in range(N-2):#Di1=Di2&Di+1_1=Di+1_2&Di1=Di2 3回連続ぞろ目
    if D[j][0]==D[j][1] and D[j+1][0]==D[j+1][1] and D[j+2][0]==D[j+2][1]:
        tf=1
        break

if tf==1:
    print("Yes")
else:
    print("No")
n=int(input())
cnt=0
for _ in range(n):
    d=input().split()
    if d[0]==d[1]:
        cnt+=1
    else:
         cnt=0
    if cnt==3:
        print("Yes")
        exit()
print("No")
n = int(input())
count = 0
lis = []
for i in range(n):
    lis.append(list(map(int, input().split())))

for i in range(n):
    if lis[i][0] == lis[i][1]:
        count += 1
    else:
        count = 0
    if count >= 3:
        break
if count >= 3:
    print("Yes")
else:
    print("No")
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')
N=int(input())
count = 0
flag = "No"
for x in range(N):
	a=input().split()
	if (a[0]==a[1]):
		count+=1
		if(count==3):
			flag = "Yes"
	else:
		count = 0
print(flag)
def main():
    N = int(input())
    cnt = 0 # 連続ゾロ目カウンター
    ans = 'No'

    for n in range(N):
        if len(set(map(int, input().split()))) == 1: # ゾロ目だったら
            cnt += 1
        else:
            cnt = 0
        if cnt >= 3:    # 三回連続で出たら
            ans = 'Yes'
    else:
        print(ans)

if __name__ == '__main__':
    main()
N = int(input())

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

ans = 0
flg = False
tmp = 0
for c,d in D:
    if c==d:
        if flg:
            tmp += 1
            ans = max(ans, tmp)
        else:
            tmp = 1
            flg = True
            ans = max(ans, tmp)
    else:
        flg = False

if ans >= 3:
    print('Yes')
else:
    print('No')
N = int(input())

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

E = [D[i][0]==D[i][1] for i in range(N)]
flag = False
for i in range(N-2):
    if E[i] and E[i+1] and E[i+2]:
        flag=True
        break

if flag:
    print("Yes")
else:
    print("No")
def abc179b():
    n = int(input())
    cnt = 0
    flg = False
    for _ in range(n):
        d1, d2 = map(int, input().split())
        if d1 == d2:
            cnt += 1
        else:
            cnt = 0
        if cnt == 3:
            flg = True
    if flg:
        print('Yes')
    else:
        print('No')
abc179b()
N = int(input())
check_list = []
for _ in range(N):
    a, b = input().split()
    if a == b:
        check_list.append(1)
    else:
        check_list.append(0)
        
total_list = []
for i in range(len(check_list) - 1):
    total_list.append(sum(check_list[i:i + 3]))

if max(total_list) >= 3:
    print('Yes')
else:
    print('No')
N = int(input())

count = 0
flag = False
for i in range(N):
    D1,D2 = map(int,input().split())
    if D1 == D2:
        count += 1
        if count >= 3:
            flag = True
    else:
        count = 0

if flag:
    print("Yes")
else:
    print("No")
N = int(input())

count = 0
ans = 0
for i in range(N):
    d1, d2 = map(int, input().split())
    if d1 == d2:
        count += 1
    else:
        count = 0
    if count == 3:
        ans += 1

if ans > 0:
    print("Yes")
else:
    print("No")
def solve():
    n = int(input())
    ct = 0
    for _ in range(n):
        a, b = input().split()
        if a == b:
            ct += 1
            if ct == 3:
                return 'Yes'
        else:
            ct = 0
    return 'No'
    

print(solve())
"""
abc179_B
"""
n = int(input())
ans = 'No'

a = [input().split() for i in range(n)]

for i in range(0,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]:
        ans = 'Yes'
        break

print(ans)
n = int(input())

cnt = 0
l = [list(map(int,input().split())) for i in range(n)]
for i in range(n):
    d1,d2 = l[i][0],l[i][1]
    if(d1==d2):
        cnt += 1
    else:
        cnt = 0
    if(cnt == 3):
        print('Yes')
        exit()

print('No')
N=int(input())
D=[]
for i in range(N):
    D.append(list(map(int,input().split())))
def total(N):
    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]:
            print('Yes')
            return
    print('No')
    return
total(N)
N = int(input())
cnt = 0
ans = 'No'
for i in range(N):
  d1,d2 = map(int, input().split())
  if d1==d2:
    cnt += 1
    if cnt==3:
      ans = 'Yes'
  else:
    cnt = 0
print(ans)
n=int(input())
cnt=0
for _ in range(n):
  d1,d2=map(int,input().split())
  if d1==d2:
    cnt += 1
  else:
    cnt = 0
  if cnt >= 3:
    print('Yes')
    break
else:
  print('No')
N = int(input())

D = [[] for i in range(N+2)]

for i in range(N) :
  a = input().split()
  D[i].append(int(a[0]))
  D[i].append(int(a[1]))
  a.clear()

D[N].append(0)
D[N].append(1)

D[N+1].append(0)
D[N+1].append(1)
  
#print('N = ', N)
#print('D = ', D)

judge = 'No'

for i in range(N) :
  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] :
    judge = 'Yes'

print(judge)
i = int(input())
count = 0
res = False
for i in range(i):
  a, b = input().split(' ')
  if a == b:
    count += 1
  else:
    count = 0
  if count >= 3:
    res = True
print('Yes' if res else 'No')
n = int(input())
count = 0
for i in range(n):
  a, b = map(int, input().split())
  if a == b:
    count += 1
  else:
    count = 0
  if count == 3:
    print('Yes')
    exit()
print('No')
def die(matrix, n):
	for i in range(n-2):
		if matrix[i][0] == matrix[i][1]:
			if matrix[i+1][0] == matrix[i+1][1]:
				if matrix[i+2][0] == matrix[i+2][1]:
					return("Yes")

	return("No")			



n = int(input())
matrix = []
for i in range(n):
   row = list(map(int, input().split()))
   matrix.append(row)


print(die(matrix, n))
N=int(input())
DD=[]
t=0

for _ in range(N):
    D=list(map(int,input().split()))
    DD.append(D)

for i in range(N-2):
    if (DD[i][0]-DD[i][1])**2+(DD[i+1][0]-DD[i+1][1])**2+(DD[i+2][0]-DD[i+2][1])**2==0:
        t=1
        break
    i+=1
if t==1:
    print('Yes')
else:
    print('No')
n=int(input())

cnt=0
ans=0

for i in range(n):
    a,b=map(int,input().split())
    if a==b:
        cnt+=1
    
    else:
        ans=max(ans,cnt)
        cnt=0

ans=max(ans,cnt)


if ans>=3:
    print('Yes')

else:
    print('No')
n = input()
x = 0
flag = False
for i in range(int(n)):
    a,b = input().split(" ")
    if a == b:
        x+=1
    else: x = 0
    if x==3:
        flag = True
if flag:
    print("Yes")
else:
    print("No")
import sys

n = int(input())

dice = []

for i in range(n):
    dice.append(list(map(int,input().split())))

c = 0

for i in range(n):
    if dice[i][0] == dice[i][1]:
        c += 1
    else:
        c = 0
    if c == 3:
        print('Yes')
        sys.exit()

print('No')
N = int(input())
D = []

count = 0
for i in range(N):
    Di = list(map(int, input().split()))
    D.append(Di)

for i in range(N):
    Di = D[i]
    if Di[0] == Di[1]:
        count += 1
    else:
        count = 0
    if count >= 3:
        print("Yes")
        break
else:
    print("No")
_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")
n = int(input())
x = 0
for i in range(n):
    d1, d2 = map(int, input().split())
    if x != 3:
        if d1 != d2:
            x = 0
        else:
            x += 1
print("Yes" if x == 3 else "No")
N = int(input())
D  = [list(map(int,input().split())) for i in range(N)]
count = 0 
k = 0 
while count < 3 and k <= N-1:
        if D[k][0] == D[k][1]:
            count += 1
        else:
            count = 0 
        k+=1
        
if count == 3:
    print('Yes')
else:
    print("No")
# -*- coding: utf-8 -*-
# B

import sys
from collections import defaultdict, deque
from heapq import heappush, heappop
import math
import bisect
input = sys.stdin.readline

# 再起回数上限変更
# sys.setrecursionlimit(1000000)

n = int(input())
d = [] * n * 2
cnt = 0
for _ in range(n):
    a, b = map(int, input().split())
    d.append(a)
    d.append(b)
    if a == b:
        cnt += 1
        if cnt == 3:
            print('Yes')
            sys.exit()
    else:
        cnt = 0
print('No')
n = int(input())

ans = "No"
x = 0
for _ in range(n):
  d1, d2 = input().split()
  if d1 == d2:
    x += 1
  else:
    x = 0

  if x == 3:
    ans = "Yes"


print(ans)
N = int(input())

ok = 0
aa = 0
for i in range(N):
    A, B = map(int, input().split())
    if A == B:
        aa += 1
    else:
        aa = aa*0
    if aa == 3:
        ok = 1


if ok == 1:
    print("Yes")
else:
    print("No")
N = int(input())
result = '0'
for i in range(N):
  d1,d2 = map(int, input().split())
  if d1 == d2:
    result += '1'
  else:
    result += '0'
if '111' in result:
  print('Yes')
else:
  print('No')
N = int(input())
A = []
B = []
s = 0
for x in range(N):
    a, b = input().split()
    a = int(a)
    b = int(b)
    A.append(a)
    B.append(b)
for i in range(N):
    if A[i] == B[i]:
        s = s+1
    else:
        if s >= 3:
            s = s + 0
        else:
            s = 0
if s >= 3:
    print('Yes')
else:
    print('No')
n = int(input())
cou = 0
ans = False
for i in range(n):
	da, db = map(int, input().split())
	if da == db:
		cou += 1
	else:
		cou = 0
	if cou == 3:
		ans = True

if ans:
	print('Yes')
else:
	print('No')
import sys
input = sys.stdin.readline
N = int(input())
D = [list(map(int, input().split())) for _ in range(N)]
result = 'No'
count = 0
for i in range(N):
    if D[i][0] == D[i][1]:
        count += 1
        if count == 3:
            result = 'Yes'
            break
    else:
        count = 0

print (result)
N = int(input())
zoro_count = 0
zoro = False
for n in range(N):
  dn1,dn2 = map(int, input().split())
  if dn1 == dn2:
    zoro_count += 1
  else:
    zoro_count = 0
  if zoro_count >= 3:
    zoro = True
if zoro:
  print('Yes')
else:
  print('No')
N = int(input())

cnt = 0
flag = 0

for i in range(N):
    d1, d2 = map(int,input().split())

    if d1 == d2:
        cnt += 1
        if cnt >= 3:
            flag = 1
    else:
        cnt = 0

if flag == 1:
    print('Yes')
else:
    print('No')
n=int(input())
c=0
ans=False
for i in range(n):
    a,b=map(int,input().split())
    if a==b:
        c+=1
    else:
        c=0
    if c==3:
        ans=True
if ans:
    print('Yes')
else:
    print('No')
import sys
from math import sqrt, gcd, ceil, log, floor
from bisect import bisect, bisect_left
from collections import defaultdict, Counter, deque
from heapq import heapify, heappush, heappop
input = sys.stdin.readline
read = lambda: list(map(int, input().strip().split()))

# MOD = 10**9 + 7
def main():
	f = 0; flag = 0
	for i in range(int(input())):
		a, b = read()
		if a == b:f+=1
		else:f = 0

		if f == 3:flag |= 1
	print("YNeos"[flag == 0::2])

		



	

if __name__ == "__main__":
	main()
N,*D=map(int,open(0).read().split())
def main():
    cnt=0
    for i in range(0,N*2,2):
        n1=D[i]
        n2=D[i+1]
        if n1==n2:
            cnt+=1
            if cnt>=3:
                return True
        else:
            cnt=0
    return False
if main():
    print("Yes")
else:
    print("No")
# URL : https://atcoder.jp/contests/abc179/tasks/abc179_b
n = int(input())
d = [list(map(int, input().split())) for _ in range(n)]
ok = False


def f(p):
    return p[0] == p[1]


for i in range(n - 2):
    a = True
    for j in range(3):
        a &= f(d[i + j])
    ok |= a
if ok:
    print('Yes')
else:
    print('No')
n = int(input())
a = []
for i in range(n):
	a.append(input().split())
for i in range(len(a)-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()
print("No")
N = int(input())
zc = 0
ret = "No"
for i in range(N):
  a,b = map(int,input().split())
  if a == b:
    zc += 1
    if zc == 3:
      ret = "Yes"
  else:
    zc = 0
print(ret)
n = int(input())

a = []
for i in range(n):
    d,e = map(int,input().split())
    a.append([d,e])


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

c = 0
for i in range(n-2):
    if b[i] == 1 and b[i+1] == 1 and b[i+2] == 1:
        c = 1
        break

if c == 1:
    print("Yes")
else:
    print("No")
n = int(input())
cnt = 0
for _ in range(n):
  a, b = map(int, input().split())
  if a == b:
    cnt += 1
  else:
    cnt = 0
  
  if cnt == 3:
    print("Yes")
    exit()

print("No")
n = int(input())
A = [[int(i) for i in input().split()] for j in range(n)]
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")
        break
else:
    print("No")
n = int(input())
c = 0
d = False
for i in range(n):
  x, y = map(int, input().split())
  if x == y:
    c += 1
  else:
    c = 0
    
  d = d or (c == 3)
print('Yes' if d else 'No')
n = int(input())
dlist = [list(map(int,input().split())) for _ in range(n)]

cnt = 0
renzoku = 0
for d in dlist:
    if d[0] == d[1]:
        cnt+=1
        renzoku += 1
    else:
        renzoku = 0
        cnt = 0
    if cnt == 3 and renzoku == 3:
        print('Yes')
        break
else:
    print('No')
n=int(input())
c=0

for i in range(n):
    d,dd=map(int,input().split())
    if d==dd:
        c+=1
        if c==3:
            print("Yes")
            exit()
    else:
        c=0
print("No")
from sys import exit
N = int(input())
 
cnt = 0
for i in range(N):
    x,y = map(int,input().split())
    if cnt == 3:
        print("Yes")
        exit(0)
    if x == y:
        cnt += 1
    else:
        cnt = 0

if cnt == 3:
    print("Yes")
else:
    print("No")
n = int(input())
d = [list(map(int,input().split())) for _ in range(n)]

ans = [i[0] == i[1] for i in d] + [False, False]
ans2 = [sum( ans[i:i+3] ) for i in range(n)]

if max(ans2) == 3:
  print('Yes')
else:
  print('No')
N=int(input())
cnt=0
flg='No'

for i in range(N):
  D1,D2=map(int,input().split())
  if D1==D2:
    cnt+=1
    if cnt==3:
      flg='Yes'
      break
  else:
    cnt=0

print(flg)
n = int(input())

ans = 0
zoro = 0

for i in range(n):
    x,y = map(int,input().split())
    if x == y:
        zoro = zoro + 1
        if ans < zoro:
            ans = zoro
    else:
        if ans < zoro:
            ans = zoro
            zoro = 0
        else:
            zoro = 0

if ans >= 3:
    print('Yes')
else:
    print('No')
n = int(input())
a = []
for i in range(n):
    x,y = map(int,input().split())
    a.append([x,y])
count = 0
flag = True
for x in a:
    if x[0] == x[1]:
        count += 1
        if count == 3:
            print('Yes')
            flag = False
            break
    else:
        count = 0

if flag:
    print('No')
n = int(input())
d = [list(map(int,input().split())) for i in range(n)]
ans = "No"
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]:
        ans = "Yes"
print(ans)
N = int(input())
D = [list(map(int,input().split())) for _ in range(N)]
flag = 0
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]:
        flag = 1
        break
if flag==1:
    print("Yes")
else:
    print("No")
n = int(input())

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

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

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

print('No')
a=0
for _ in range(int(input())):
    i,j=map(int,input().split())
    if i==j:
        a+=1
        if a>=3:
            print("Yes")
            exit()
    else:a=0
print("No")
N=int(input())

cnt=0

for i in range(N):
  D1,D2=map(int,input().split())
  if D1!=D2:
    cnt=0
  else:
    cnt+=1
    if cnt==3:
      print("Yes")
      exit()

print("No")
n = int(input())
D = [list(map(int, input().split())) for _ in range(n)] 
ct = 0
CT = []
for i in range(n):
    if D[i][0] == D[i][1]:
        ct += 1
        if i == n-1:
            CT.append(ct)
    else:
        CT.append(ct)
        ct = 0
for k in CT:
    if k >= 3:
        print('Yes')
        exit()
print("No")
# -*- coding: utf-8 -*-
N = int(input())
count = 0
flag = False
for i in range(N):
  Di, Dj = map(int, input().split())
  if Di == Dj:
    count += 1
    if count == 3:
      flag = True
  else:
    count = 0
if flag == True:
  print("Yes")
else:
  print("No")
N = int(input())

flag = 0

for i in range(N):
  a, b = map(int,input().split())
  if a == b:
    flag += 1
    if flag == 3:
      print("Yes")
      exit()
  else:
    flag = 0
print("No")
c=int(input())
ans=0
now=0
for _ in range(c):
  if eval(input().replace(" ","==")):
    now = now+1
  else:
    now = 0
  ans = max(ans,now)
print("Yes") if ans >= 3 else print("No")
N = int(input())
cnt = 0
for _ in range(N):
    a, b = map(int, input().split())
    if a == b:
        cnt += 1
    else:
        cnt = 0
    if cnt == 3:
        print('Yes')
        exit()
print('No')
import sys

N = int(input())
B=[]
for i in range(N):
    b=list(map(int,input().split()))
    B.append(b)
for i in range(N-2):
    if B[i][0]==B[i][1]:
        if B[i+1][0]==B[i+1][1]:
            if B[i+2][0]==B[i+2][1]:
                print("Yes")
                sys.exit()
print("No")
n = int(input())
d = [input().split() for i in range(n)]
total = 0

for i in range(n):
    if  len(set(d[i])) == len(d[i]):
        if total >=3:
            total +=0
        else:
            total = 0
    else:
        total += 1

if total >= 3:
    print("Yes")
else:
    print("No")
n = int(input())
check = []
ans = 0
for _ in range(n):
    n1, n2 = map(int, input().split())
    if n1 == n2:
        check.append(1)
    else:
        check.append(0)

for i in range(n-1):
    if sum(check[i:i+3])==3:
        ans = 1
        break
if ans:
    print("Yes")
else:
    print("No")
N = int(input())
x = [list(map(int, input().split())) for i in range(N)]

counter = 0
max = 0
for i in range(N):
  if x[i][0] == x[i][1]:
    counter = counter + 1
  else:
    if max < counter:
      max = counter
    counter = 0

if max >=3 or counter >= 3:
  a = 'Yes'
else:
  a = 'No'
    
print(a)
from sys import stdin
input = stdin.readline

N = int(input())

cnt = 0

for _ in range(N):
    a, b = map(int, input().split())
    if a == b:
        cnt += 1
    else:
        cnt = 0

    if cnt >= 3:
        print("Yes")
        exit()

print("No")
time = int(input())
xy = [map(int, input().split()) for _ in range(time)]
x, y = [list(i) for i in zip(*xy)]
sum = 0
for i in range(time):
    if x[i] == y[i]:
        sum += 1
        if sum == 3:
            print("Yes")
            break
    else:
        sum = 0

if sum < 3:
    print("No")
def resolve():
    n = int(input())
    flag = False
    count = 0
    for i in range(n):
        d = list(map(int, input().split()))
        if d[0] == d[1]:
            count += 1
        else:
            count = 0
        if count == 3:
            flag = True
            break
    print('Yes' if flag else 'No')


if 'unittest' not in globals():
    resolve()