peterverebics/CodeNet_Python_118 huggingface dataset:
n=int(input())
D = [list(map(int,input().split())) for i in range(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")
    break
else:
  print("No")
n = int(input())
li = [0]*n
for i in range(n):
    d1,d2 = map(int,input().split())
    if d1==d2:
        li[i] = 1
lii = [0]*n
lii[0]=li[0]
for i in range(n-1):
    if li[i+1]==1:
        lii[i+1]=lii[i]+li[i+1]
    else:
        lii[i+1]=0

if max(lii)>=3:
    print("Yes")
else:
    print("No")
n=int(input())
q=[]
for _ in range(n):
    d_1,d_2=map(int,input().split())
    if d_1==d_2:
        q.append(1)
    else:
        q.append(0)
for i in range(n-2):
    if q[i]==q[i+1]==q[i+2]==1:
        print("Yes")
        exit()
print("No")
def main():
    n = int(input())

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


if __name__ == '__main__':
    main()
n = int(input().rstrip())
cnt = 0
flg = False
d_list = [[0, 0] for i in range(n)]
for i in range(n):
  d_list[i] = list(map(int, input().rstrip().split(" ")))
for ds in d_list:
  if ds[0] == ds[1]:
    cnt += 1
  else:
    cnt = 0
  if cnt >= 3:
    flg = True
    break
if flg:
  print("Yes")
else:
  print("No")
import sys

def main():
    N = int(sys.stdin.readline().rstrip())

    cnt = 0
    ans = "No"
    for i in range(N):
        a,b = map(int, sys.stdin.readline().rstrip().split())
        if a == b:
            cnt += 1
        else:
            cnt =0
        
        if cnt == 3:
            ans = "Yes"

    print(ans)


main()
LI = lambda: list(map(int, input().split()))

N = int(input())
D = [LI() for _ in range(N)]


def main():
    m = 0
    x = 0
    for a, b in D:
        if a == b:
            x += 1
            m = max(m, x)
        else:
            x = 0
    ans = "Yes" if m >= 3 else "No"
    print(ans)


if __name__ == "__main__":
    main()
import numpy as np
n = int(input())
d = np.array([input().split() for i in range(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")
        exit()

print("No")
n=int(input())
s=0
l=0
for i in range(n):
    b,c=map(int,input().split())
    if b==c:
        l+=1
    else:
        l=0
    if l>=3:
        s+=1

if s==0:
    print("No")
else:
    print("Yes")
n = int(input())
a = []
res = False
for i in range(n):
    x, y = map(int, input().split())
    a.append(x == y)
    if i >= 2 and a[-1] and a[-2] and a[-3]:
        res = True
print('Yes' if res else 'No')
N = int(input())
ans = 0
for i in range(N):
  x, y = map(int, input().split())
  if x == y:
    ans += 1
  else:
    ans = 0
  if ans == 3:
    break
if ans == 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())
cnt = 0
ans = "No"
for i in range(n):
    d1, d2 = map(int,input().split())
    if d1 == d2:
        cnt += 1
    else:
        cnt = 0
    if cnt == 3:
        ans = "Yes"
print(ans)
n = int(input())
c = 0
for i in range(n):
    a,b = map(int,input().split())
    if a == b:
        c += 1
    else:
        c = 0
    if c == 3:
        break
if c == 3:
    print("Yes")
else:
    print("No")
N = int(input())

D1, D2 = [0] * N, [0] * N

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

    D1[i], D2[i] = a, b

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")
        exit()

print("No")
N = int(input())

i = 0
res = False

for _ in range(N):  
    a, b = map(int,input().split())

    if a == b:
        i += 1
    else:
        i = 0
        
    if i >= 3:
        res = True

print("Yes" if res else "No")
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')
import sys
import math
def get_array(): return list(map(int, sys.stdin.readline().strip().split()))
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def input(): return sys.stdin.readline().strip()
n=int(input())
ans=0
flag=0
for i in range(n):
    d1,d2=get_ints()
    if d1==d2:
        ans=ans+1
        if ans>=3:
            flag=1
    else:
        ans=0
if flag==1:
    print("Yes")
else:
    print("No")
n =  int(input())
d = [list(map(int,input().split())) for i in range(n)]
cnt = 0

for i in range(n):
    if d[i][0] == d[i][1]:
        cnt += 1
        if cnt == 3:
            print('Yes')
            break
    else:
        cnt = 0
else:
    print('No')
N = int(input())

cnt = 0
for i 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())

c = 0
flag = False

for i in range(n):
    x, y = list(map(int, input().split()))
    if x == y:
        c += 1
        if c == 3:
            flag = True
            break
    else:
        c = 0

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

d = [ list(map(int,input().split())) for i in range(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")
        break
else:
    print("No")
n=int(input())
d1=[]
d2=[]
f=0
for i in range(n):
    x,y=map(int, input().split())
    d1.append(x)
    d2.append(y)
for i in range(2,n):
    if d1[i]==d2[i] and d1[i-1]==d2[i-1] and d1[i-2]==d2[i-2] :
        f=1
if f==1:
    print('Yes')
else:
    print('No')
n = int(input())
cnt = 0
flg = False
for i in range(n):
  a,b = list(map(int,input().split()))
  if a == b:
    cnt +=1
    if cnt > 2:
      flg = True
  else:
    cnt = 0
if flg:
  print('Yes')
else:
  print('No')
def solve():
    N = int(input())

    D1 = [0] * N
    D2 = [0] * N

    for i in range(N):
        D1[i], D2[i] = map(int, input().split())

    c = 0
    judge = 0

    for i in range(N):
        if D1[i]==D2[i]:
            c += 1
        else:
            c = 0

        if c>2:
            judge += 1

    if judge!=0:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    solve()
N=int(input())
flag=0
count=0
for i in range(N):
    d1,d2=map(int,input().split())
    if(d1==d2):
        count+=1
    else:
        count=0
    if(count==3):
        flag=1
        break
if(flag==1):
    print("Yes")
else:
    print("No")
n= int(input())
cont=0
yes=0
for x in range(n):
    a,b= input().split()
    a, b= int(a), int(b)
    if a==b:
        cont+=1
    else:
        cont=0
    if cont>=3:
        yes=1
if yes==1:
    print("Yes")
else:
    print("No")
N = int(input())

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

count = 0
for i in range(N):
    if D[i][0] == D[i][1]:
        count += 1
        if count == 3:
            break
    else:
        count = 0

print("Yes") if count == 3 else print("No")
N = int(input())
flag = 0
ans = "No"
for i in range(N):
  A,B = input().split()
  if A == B:    
    flag += 1
  else:
    flag = 0
  if flag == 3:
    ans = "Yes"
    break
    
print(ans)
n=int(input())
cnt=0
for i in range(n):
  a,b=map(int,input().split())
  if a==b:
    cnt+=1
    if cnt==3:
      print("Yes")
      exit()
  else:
    cnt=0
print("No")
n = int(input())
count = 0
ans = "No"
for i in range(n):
    a,b = input().split()
    if a == b:
        count += 1
    else:
        count = 0
    if count == 3:
        ans ="Yes"
        
print(ans)
N = int(input())

xy = [map(int,input().split()) for _ in range(N)]
x,y = [list(i) for i in zip(*xy)]

ans = 0
flag = False

for i in range(N):
    if x[i] == y[i]:
        ans +=1
    elif ans >= 3:
        flag = True
        ans = 0
    else:
        ans = 0
        
if ans >= 3  or flag ==True:
    print("Yes")
    
else:
    print("No")
N = int(input())
D = [list(map(int,input().split())) for x in range(N)]
flag = ""

for p in range(N):
    if D[p][0] == D[p][1]:
        flag += "1"
    else:
        flag += "0"

if "111" in flag:
    print("Yes")
else:
    print("No")
n=int(input())
a=0
h=0
for i in range(n):
    x,y=map(int,input().split())
    if x==y:
        a=a+1
    else:
        a=0
    if a==3:
        h=1
if h==1:
    print("Yes")
else:
    print("No")
print('NYoe s'[' 1 1 1'in' '.join(str(len({*t.split()}))for t in open(0))::2])
import sys
input = sys.stdin.readline


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

    zorome_count = 0
    for d in D:
        if d[0] == d[1]:
            zorome_count += 1
        else:
            zorome_count = 0
        if zorome_count == 3:
            break

    print('Yes' if zorome_count == 3 else 'No')


if __name__ == "__main__":
    main()
def checkDoublet(arr):
    count = 0
    for d in arr:
        if d[0] == d[1]:
            count += 1
            if count >= 3:
                return 'Yes'
        else:
            count = 0
    return 'No'

n = int(input())
arr = []
for i in range(n):
    arr.append(list(map(int, input().rstrip().split())))
print(checkDoublet(arr))
def main():
    N = int(input())
    zorome_count = 0
    for i in range(N):
        d1, d2 = map(int, input().split())
        if d1 == d2:
            zorome_count += 1
        else:
            zorome_count = 0
        
        if zorome_count == 3:
            print('Yes')
            return
    print('No')

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

ans  = 0
for i in range(N):
    d1,d2 = map(int, input().split())
    if d1 == d2:
        ans += 1
        if ans == 3:
            print("Yes")
            exit()
    else:
        ans = 0
else:
    print("No")
# author:  Taichicchi
# created: 19.09.2020 21:01:22

import sys

N = int(input())

c = 0


for i in range(N):
    d1, d2 = map(int, input().split())
    if d1 == d2:
        c += 1
    else:
        c = 0
    if c == 3:
        print("Yes")
        exit()

print("No")
N = int(input())
count = 0
flg = False
for i in range(N):
    
    d1,d2 = map(int,input().split())
    if d1 == d2:
        count += 1
        if count ==3:
            flg = True
    else:
        count = 0
if flg:
    print("Yes")
else:
    print("No")
n = int(input())
d = [list(map(int, input().split()))for _ in range(n)]

cnt = 0
for i, (p, q) in enumerate(d):
    if p == q:
        cnt += 1
    else:
        cnt = 0
    if cnt == 3:
        print("Yes")
        break
else:
    print("No")
n = int(input())

a = [0]*n

for i in range(n):
    d1, d2 = map(int, input().split())
    if d1 == d2:
        a[i] = 1
ans = 'No'        
for i in range(n-2):
    if a[i]*a[i+1]*a[i+2] ==1:
        ans = 'Yes'
        
print(ans)
def main():
    import sys
    N=int(sys.stdin.readline())
    count=0
    for i in range(N):
        D1,D2=list(map(int,sys.stdin.readline().split()))
        if D1==D2:
            count+=1
        else:
            count=0
        if count==3:
            print('Yes')
            break
    else:
        print('No')

main()
def myfunc():
    N = int(input())

    counter = 0
    for i in range(N):
        A, B = map(int, input().split())
        if A == B:
            counter += 1
            if counter >= 3:
                print('Yes')
                return 0
        else:
            counter = 0
    print('No')

if __name__ == "__main__":
    myfunc()
N = int(input())
D = [None] * N
for i in range(N):
    D[i] = list(map(int, input().split()))
for i in range(N-2):
    for j in range(3):
        if D[i+j][0] != D[i+j][1]:
            break
    else:
        print('Yes')
        exit()
print('No')
# import sys; input = sys.stdin.buffer.readline
# sys.setrecursionlimit(10**7)
from collections import defaultdict
mod = 10 ** 9 + 7; INF = float("inf")

def getlist():
	return list(map(int, input().split()))

def inverse(N, mod):
	return (pow(N, mod - 2, mod))

def main():
	N = int(input())
	L = []
	for i in range(N):
		D1, D2 = getlist()
		if D1 == D2:
			L.append(1)
		else:
			L.append(0)

	for i in range(N - 2):
		if L[i] + L[i + 1] + L[i + 2] == 3:
			print("Yes")
			return

	print("No")




if __name__ == '__main__':
	main()
N=int(input())
sum=0
ans="No"
for i in range(N):
    d=list(map(int,input().split()))
    if d[0]==d[1]:
        sum+=1
        if sum>2:
            ans="Yes"
            break
    else:
        sum=0
print(ans)
import sys
S = int(input())
xy = [map(int, input().split()) for _ in range(S)]
x, y = [list(i) for i in zip(*xy)]
count = 0

for i in range(S):
  if x[i] == y[i]:
    count += 1
    if count == 3:
      print("Yes")
      sys.exit()
    else:
      pass
  else:
    count = 0
print("No")
n = int(input())

dices = []

successive_cnt = 0

for i in range(n):
    d, e = [int(x) for x in input().split(' ')]

    if d == e:
        successive_cnt += 1
    else:
        successive_cnt = 0

    if successive_cnt == 3:
        break

if successive_cnt == 3:
    print('Yes')
else:
    print('No')
N = int(input())
D = [list(map(int, input().split())) for i in range(N)]
for i in range(N-2):
    if D[i][0] == D[i][1]:
        if D[i+1][0] == D[i+1][1] and D[i+2][0] == D[i+2][1]:
            print('Yes')
            exit()
print('No')
N = int(input())
D = [list(map(int, input().split())) for _ in range(N)]

ans = "No"
cnt = 0

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

print(ans)
L=0
N=int(input())
for i in range(N):
  a,b=map(int,input().split())
  if a==b:
    L+=1
    if L==3:
      print("Yes")
      exit()
  else:
    L=0
print("No")
# coding: utf-8

def main():
    n = int(input())
    count = 0
    for _ in range(n):
        d1, d2 = map(int, input().split())
        if d1 == d2:
            count += 1
        else:
            count = 0
        if count >= 3:
            print('Yes')
            return
    print('No')
    
main()
N = int(input())
number = [0]*N
for i in range(N):
    a,b = map(int,input().split())
    if a==b:
        number[i]=1

for i in range(N-2):
    if number[i]==1 and number[i+1]==1 and number[i+2]==1:
        print("Yes")
        exit(0)

print("No")
#coding:utf-8

N = int(input())

D = []

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

    D.append(d1==d2)
    
for i in range(N-2):
    if D[i] and D[i+1] and D[i+2]:
        print("Yes")
        break

    if i == N-3:
        print("No")
n = int(input())  # nは入力回数
num_list = [list(map(int, input().split())) for _ in range(n)]
ans = "No"

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

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

now = 0

ans = "No"

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

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

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

if flag:
  print("Yes")
else:
  print("No")
n=int(input())
arr=[]
for i in range(n):
	arr.append(list(map(int,input().split())))
flag=0
for i in range(n-2):
	if(arr[i][0]==arr[i][1] and arr[i+1][0]==arr[i+1][1] and arr[i+2][0]==arr[i+2][1]):
		flag=1
		print("Yes")
		break
if(flag==0):
	print("No")
c=0
for _ in range(int(input())):
    a,b=map(int,input().split())
    if a==b:
        c+=1
        if c==3:
            print("Yes")
            break
    else:
        c=0
else:
    print("No")
n = int(input())
a = []
for i in range(n):
    l,m = map(int,input().split())
    a.append([l,m])
f = 0
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]:
        f = 1
if f == 0:
    print('No')
else:
    print('Yes')
count = 0
for i in range(int(input())):
    l = list(map(int, input().split()))
    if l[0] == l[1]:
        count += 1
    elif l[0] != l[1]:
        count = 0
    if count >= 3:
        print("Yes")
        break
if count < 3:
    print("No")
N = int(input())
D = [False for _ in range(N)]
for i in range(N):
    x, y = map(int, input().split())
    if x == y:
        D[i] = True
tmp = 0
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())
def count():
    count = 0
    result = ''
    for i in range(n):
        d1, d2 = map(int, input().split())
        if result == 'Yes':
            continue
        if d1 == d2:
            count += 1
            if count == 3:
                result = 'Yes'
        else:
            count = 0
            result = 'No'
    return result

print(count())
n = int(input())
d = [list( map( int, input().split() ) ) for i in range(n)]

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

ans = 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]:
        ans += 1
    else:
        ans += 0
        
if ans >= 1:
    print("Yes")
else:
    print("No")
n = int(input())
cnt = 0
ok = False
for _ in range(n):
    x, y = map(int, input().split())
    if x == y:
        cnt += 1
        if cnt >= 3:
            ok = True
    else:
        cnt = 0
print('Yes' if ok else 'No')
N = int(input())

D = []
for i in range(N):
    Da,Db = (map(int,input().split()))
    if Da == Db:
        D.append(1)
    else:
        D.append(0)

for i in range(N-2):
    if D[i]==1 and D[i+1] == 1 and D[i+2] == 1:
        ans = "Yes"
        break
    else:
        ans = "No"
print(ans)
N = int(input())

count = 0
ans = "No"
for i in range(N):
    d1,d2 = map(int,input().split())
    if d1 == d2:
        count += 1
        if count == 3:
            ans = "Yes"
    else:
        count = 0
print(ans)
n = int(input())
cnt = 0
for i in range(n):
    a, b = map(int, input().split())
    if a == b: 
        cnt += 1
    else:
        cnt = 0
    if cnt >= 3:
        print("Yes")
        break
    if cnt < 3 and i == n-1:
        print("No")
n=int(input())
l=[list(map(int,input().split())) for _ in range(n)]
for i in range(n-2):
  if l[i][0]==l[i][1] and l[i+1][0]==l[i+1][1] and l[i+2][0]==l[i+2][1]:
    print('Yes')
    exit()
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
            break
    else:
        cnt = 0

if flag == 0:
    print('No')
else:
    print('Yes')
N = int(input())
zoro = []
for _ in range(N):
    a, b = map(int, input().split())
    zoro.append(a == b)

for i in range(N - 2):
    if zoro[i] and zoro[i + 1] and zoro[i + 2]:
        print("Yes")
        exit()
        
print("No")
n = int(input())
results = [list(map(int, input().split())) for _ in range(n)]
ans = 0

for i in range(n):
    if ans >= 3:
        break
    if results[i][0] == results[i][1]:
        ans += 1
    else:
        ans = 0
if ans >= 3:
    print("Yes")
else:
    print("No")
N = int(input())
D = [input().split() for i in range(N)]
ans = 0
for i in range(N-2):
    if D[i][0] == D[i][1]:
        if D[i+1][0] == D[i+1][1]:
            if D[i+2][0] == D[i+2][1]:
                ans = 1
                break
if ans == 0:
    print('No')
else:
    print('Yes')
num = int(input())
count = 0
for i in range(num):
  ab = input().split(" ")
  a = int(ab[0])
  b = int(ab[1])
  if a == b:
    count += 1
    if count >= 3:
      break
  else:
    count = 0
if count >= 3:
  print("Yes")
else:
  print("No")
import sys
n = int(input())
ans = 0
flag = False
for i in range(n):
    d1,d2 = map(int,input().split())
    if d1 == d2:
        ans += 1
    else:
        ans = 0
    if ans == 3:
        flag = True
if flag == True:
    print("Yes")
else:
    print("No")
N=int(input())
D=[map(int, input().split()) for i in range(N)]
x, y = [list(i) for i in zip(*D)]

s=0
l=[]
for i in range(N):
  if x[i]==y[i]:
    s+=1
    if i==N-1:
      l.append(s)
  elif x[i]!=y[i]:
    l.append(s)
    s=0

if max(l)>=3:
  print("Yes")
else:
  print("No")
N = int(input())

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

    if x >= 3:
        print("Yes")
        break
else:
    print("No")
def main():
    from sys import stdin

    readline = stdin.readline

    N=int(readline().rstrip())
  
    count=0
    
    for i in range(N):
        x,y = list(map(int,readline().rstrip().split()))
        if ( x == y ):
            count += 1
            if ( count >= 3):
                break
        else:
            count = 0


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

main()
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
n=int(input().rstrip())
cnt=0
tmp=0
for i in range(n):
    a,b=map(int,input().split())
    if a==b:
        tmp+=1
    else:
        cnt=max(cnt,tmp)
        tmp=0
cnt=max(cnt,tmp)

if cnt>=3:
    print("Yes")
else:print("No")
n = int(input())
flg = False
tmp = 0
ans = 0
for i in range(n):
	a, b = map(int, input().split())
	if not flg and a == b:
		tmp = 1
		flg = True
	elif flg and a == b:
		tmp += 1
	else:
		tmp = 0
	ans = max(ans, tmp)
print("Yes" if ans >= 3 else "No")
import sys
input = sys.stdin.readline

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:
        break

if cnt == 3:
    print('Yes')
else:
    print('No')
n = int(input())

cnt = 0
for i in range(n):
    d1,d2 = map(int,input().split())
    if d1 == d2:
        cnt += 1
        if cnt == 3:
            print("Yes")
            exit()
    else:
        cnt = 0
else:
    print("No")
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
cnt=0
for i in range(n-2):
    if (l[i][0]==l[i][1]) and (l[i+1][0]==l[i+1][1]) and (l[i+2][0]==l[i+2][1]):
        print("Yes")
        exit()
print("No")
# 初期入力
import sys
input = sys.stdin.readline  #文字列では使わない
N = int(input())
renzoku =0
ans ="No"
for _ in range(N):
    d1,d2 = map(int, input().split())
    if d1 ==d2:
        renzoku +=1
        if renzoku ==3:
            print("Yes")
            sys.exit()
    else:
        renzoku =0
print(ans)
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(0,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)
n = int(input())
total = 0
for i in range(n):
  d = list(map(int,input().split()))
  if d[0]==d[1]:
    if total != 0:
      total +=1
      if total ==3:
        print('Yes')
        break
    else:
      total = 1
  else:
    total = 0
if total !=3:
  print('No')
N = int(input())
D1 = [0]*N
D2 = [0]*N

for i in range(N):
  D1[i], D2[i] = map(int, input().split())
  
a = 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]:
    a = 1
    
if a == 1:
  print("Yes")

else:
  print("No")
N = int(input())
D = [list(map(int, input().split())) for _ in range(N)]

for i in range(2, N):
  if D[i - 2][0] == D[i - 2][1] and D[i - 1][0] == D[i - 1][1] and D[i][0] == D[i][1]:
      print('Yes')
      exit()
      
print('No')
a = int(input())
l = []
c,f =0, 0
for i in range(a):
    ta,tb = map(int,input().split())
    if ta==tb : c+=1
    else: c = 0
    if c>=3 : f = 1
if f:
    print("Yes")
else:
    print("No")