peterverebics/CodeNet_Python_118 huggingface dataset:
n = int(input())
c, d = [], []
for i in range(n):
    a, b = [int(i) for i in input().split()]
    c.append(a)
    d.append(b)

count = 1

for i in range(0, n):
    if c[i] == d[i]:
        count += 1
    else:
        count = 1
    if count == 3:
        break

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

else:
    print('No')
n = int(input())
for _ in range(n):
    a, b = map(int, input().split())
    if a == b:
        print("Yes")
        exit()
print("No")
N=int(input())
counter=0
flag=0
for i in range(N):
     D1, D2=map(int,input().split())
     if D1==D2:
         counter+=1
     else:
         counter=0
         if counter>=3:
             flag=1
             break
if flag==1:
    print('Yes')
else:
    print('No')
N=int(input())
D=[list(map(int, input().split())) for i in range(N)]
count=0
for j in range(N-2):
    if D[j][0]==D[j][1]:
        if D[j+1][0]==D[j+1][1]:
            if D[j+2][0]==D[j+2][1]:
                count = 1
if count==0:
    print('NO')
else:
    print('Yes')
n = int(input())
c, d = [], []
for i in range(n):
    a, b = [int(i) for i in input().split()]
    c.append(a)
    d.append(b)

count = 1

for i in range(1, n):
    if c[i-1] == c[i] and d[i-1] == d[i]:
        count += 1
    else:
        count = 1
    if count == 3:
        break

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

else:
    print('No')
# coding:utf-8
n = int(input())
count = 0
ans = 0

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

    if d1 == d2:
        count += 1
    else:
        ans = count
        count = 0

ans = max(ans, count)

if ans >= 3:
    print('Yes')
else:
    print('No')
N = int(input())
flag = 0
ans = "No"
for i in range(N):
  A,B = input().split()
  if flag == 3:
    ans = "Yes"
  if A == B:    
    flag += 1
  else:
    flag = 0
    
print(ans)
# https://atcoder.jp/contests/abc179/tasks/abc179_b
t = int(input())
count = 0
pre = 0
test = ''
for i in range(t):
    a, b = map(int, input().split())
    if (a == b):
        test = 'Yes'
        pre = 1
    else:
        pre = 0
        test = 'No'
    if test == 'Yes' and (pre == 1):
        count += 1
        test = 'Yes'
        pre = 1
if (count == 3) or (count == 6):
    print('Yes')
else:
    print('No')
"""
abc179_B
"""
n = int(input())
ans = 'No'

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

for i in range(0,n-3):
    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]:
    #if a[i,0] == a[i,1] and a[i+1,0] == a[i+1,1] and a[i+2,0] == a[i+2,0]:
        ans = 'Yes'
        break

print(ans)
def solve(n, d):
    n -= 2
    for i in range(n):
        for j in range(i + 1, n):
            if all(d[i + k][0] == d[i + k][1] for k in range(3)):
                return True
    return False


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


if __name__ == '__main__':
    main()
x=int(input())
l=[]
c=0
for i in range(x):
    a,b = map(int,input().split())
    l.append(a)
    l.append(b)
for i in range(0,x*2,2):
    if l[i]==l[i+1]:
        c+=1
        print(l[i])
        if c>=3:
            print("YES")
            break

    else:
        c=0
if c<3:
    print("NO")
print(c)
num = int(input())
count = 0
tmp = 0
for i in range(num):
    d1, d2 = map(int,input().split())
    if d1 == d2 and tmp == 0:
        count = 1
        tmp += 1
    elif d1 == d2 and tmp > 0:
        count += 1
        tmp += 1
    else:
        tmp = 0

print("Yes" if count >= 3 else "No")
n = int(input())
d = []
z = 0

for i in range(n):
  d1, d2 = map(int, input().split())
  z = z+1 if d1==d2 else 0
  d.append(z)

print(max(d))
N= int(input())
a = [input().split() for i in range(N)]

Is = []
for i in range(N):
    Ds = a[i]
    if Ds[0] == Ds[1]:
        Is.append(i)

Boooo = False
for i in range(len(Is)-2):
    if Is[i] == Is[i+1] and Is[i+1] == Is[i+2]:
        Boooo = True

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

count = 0
flag = 0

for i in range(N):
  N,M = map(int, input().split())
  if N == M:
    count += 1
  else:
    count = 0
  if count >= 3:
    flag = 1
   
if flag == 1:
  print("yes")
else:
  print("no")
N = int(input())
D = [input().split() for _ in range(N)]
ans = "no"
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 = "yes"
                break
print(ans)
l=[]
n=int(input())
for _ in range(n):
  a=list(map(int,input().split()))
  l.append(a)

flag=0
for i in range(1,n-1):
  if l[i-1][0]==l[i-1][1] and  l[i][0]==l[i][1] and  l[i+1][0]==l[i+1][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
print('Yes' if count > 2 else 'No')
n = input()
x = 0
for i in range(int(n)):
    a,b = input().split(" ")
    if a == b:
        x+=1
    else: x = 0
    if x==3:
        print("Yes")
        break
if x==0:
    print("No")
n = int(input())

count = 0
max_count = 0
for i in range(n):
    input_elements = input().split()
    if input_elements[0] == input_elements[1]:
        count += 1
    else:
        max_count = count
        count = 0

if max_count < count:
    max_count = count

if max_count >= 3:
    print("Yes")
else:
    print("No")
n = int(input())

cnt = 0
flg = 0

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

    if a == b:
        cnt += 1
        if cnt >= 3:
            flg = 1
    else:
        cnt = 0

    print(cnt)
    print(flg)

if flg == 1:
    print("Yes")
else:
    print("No")
n = int(input().strip())
count = 0
for i in range(n):
  a,b = map(int,input().strip().split())
  if a == b and count == 3:
    print('Yes')
    exit(0)
  elif a == b:
    count += 1
  elif(a != b):
    count = 0
print('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"
    else:
        ans = "No"
print(ans)
import sys
input = sys.stdin.readline
from collections import *

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

for i in range(N-3):
    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())
cnt=0
ans=0
for i in range(n):
    d,e=map(int,input().split())
    if d!=e:
        if cnt==3:
            ans=0
            break
        cnt=1
    else:
        cnt+=1
        if cnt==3:
            ans=1
            break
if cnt>=3:
    ans=1
if ans==1:
    print("Yes")
else:
    print("No")
n = int(input())
l = [list(map(int, input().split())) for i in range(n)]
#print(l[0][0])
#print(l[0][1])
ans = n-3
ans1 = 0

for m in range(ans):
  if l[m][0]  == l[m][1] and l[m+1][0] == l[m+1][1] and l[m+2][0] == l[m+2][1]:
    ans1 += 1
  else:
    ans1 = 0
    
    
if ans1 >= 1:
  print("Yes")
else:
  print("No")
n = int(input())
l = []
for _ in range(n):
    d1,d2 = map(int,input().split())
    l.append(d1)
    l.append(d2)

for i in range(len(l)-2):
    if l[i] == l[i+1] == l[i+2] == 3:
        print ('Yes')
        exit ()
print ('No')
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')
n = int(input())
arr= []
for i in range(n):
  z = [ int(i) for i in input().split()]
  arr.append(z)
  
count = 0 
for i in range(n):
  
    if arr[i][0] == arr[i][1]:
      count+=1
cu = 0
for i in range(n):
  for j in range(n):
    if i == j:
      continue 
    if arr[i][0]==arr[j][0]:
      cu +=1
    if arr[i][1] == arr[j][1]:
      cu +=1
    if cu>=1:
      break
      
if count>=3 and cu>=1:
  print("Yes")
else:
  print("No")
# -*- coding: utf-8 -*-
a = int(input())
xy = [map(int, input().split()) for _ in range(a)]
x, y = [list(i) for i in zip(*xy)]
flag = 0
for i in range(a):
    if (x[i] == y[i]):
      flag = flag+1
    else:
      flag = 0
if flag >= 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]
    print(Count)
    ans.append(Count)
print(max(ans))
if max(ans) >= 2:
    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
if count >= 3:
    print("Yes")
else:
    print("No")
N = int(input())
xy = [map(int, input().split()) for _ in range(N)]
x, y = [list(i) for i in zip(*xy)]
flag = 0
count = 0

for i in range(N-1):
  if x[i] == y[i]:
    count += 1
    if count >= 3:
      flag = 1
  else:
    count = 0
  

if flag == 1:
  print('Yes')
else:
  print('No')
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
    if i == N-1:
        print('No')
n = int(input())
cnt = 0
flg = False

for i in range(n):
    d1, d2 = map(int, input().split())
    if cnt == 0 and d1 == d2:
        cnt += 1
    if cnt > 0:
        if d1 == d2:
            cnt += 1
        else:
            cnt = 0
    if cnt == 3:
        flg = True
        
if flg:
    print('Yes')
else:
    print('No')
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-3):
    if cnt[i] and cnt[i+1] and cnt[i+2]:
        ans = 'Yes'

print(ans)
n=int(input())
count=0
for i in range(n):
    d1,d2=list(map(int,input().split()))
    if d1==d2:
        count+=1
if count>=3:
    print('YES')
else:
    print('NO')
input=__import__('sys').stdin.readline
ans='NO'
cs=0
for i in range(int(input())):
	a,b=map(int,input().split())
	if a==b:cs+=1
	else:cs=0
	if cs>=3:ans='YES'
print(ans)
n = int(input())
c = 0
for x in range(n):
  a,b = map(int,input().split())
  if a==b:
    c+=1
    if c==3:
      print('Yes')
      break
  else:
    c=0
N=int(input())
ans=0
ke=0
for i in range(N):
    D,E=map(int,input().split())
    if D==E:
        ans+=1
    if ans>=3:
        ke=1
if ke==1:
    print("Yes")
else:
    print("No")
n=int(input())
for i in range(0,n):
  count=0
  m,p=input().split() 
  if(m==p):
    count=count+1
if(count%3==0):
  print("Yes")
else:
    print("No")
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-3):
    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')
# -*- coding: utf-8 -*-
# 入力
N = int(input())

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

num = 0
cont = 0
for i in l:
    if(i[0]==i[1]):
        num = num + 1
        cont = cont +1
    else:
        num = 0
        cont = 0

if (cont >=3):
    print("yes")
else:
    print("no")
N = int(input())
count = 0
count_max = count
for i in range(N):
    di_1, di_2 = [int(i) for i in input().split()]
    if di_1 == di_2:
        count += 1
    else:
        count_max = max([count_max, count])
        count = 0
if count >= 3:
    print("Yes")
else:
    print("No")
N = int(input())
D = [list(map(int, input().split())) for _ in range(N)]
i = 0
count = 0
while i < N:
    if D[i][0] == D[i][1]:
        count += 1
    else:
        count = 0
    i += 1

if count >= 3:
    print("Yes")
else:
    print("No")
n = int(input())  
num_list = []
for i in range(n):
    num_list.append(list(map(int,input().split())))

ans = []
for i in range(n):
  a = num_list[i]
  a1= a[0]
  a2 = a[1]
  if a1 == a2:
    ans.append(1)
    if i > 2 and ans[i-2] == 1 and ans[i-1] == 1 and ans[i] == 1:
      print('Yes')
      break
  else:
    ans.append(0)
if len(ans) == n:
  print('No')
N = int(input())
D = 0

for i in range(N):
    D1, D2 = map(int, input().split())
    if D < 0:
        D = 0
    elif D == 3:
        print('Yes')
        break

    if D1 == D2:
        D += 1

    elif D1 != D2:
        D -= 1

if D != 3:
    print('No')
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")
elif count < 3:
    print("No")
n = int(input())
df_de = [list(map(int, input().split())) for _ in range(n)]
ans = 0
cand = []
for d1, d2 in df_de:
    if d1 == d2:
        ans += 1
    else:
        cand.append(ans)
        ans = 0
print("Yes" if len([i for i in cand if i >= 3]) else "No")
# coding: utf-8
# Your code here!

dice = int(input())

s = []
for i in range(1, dice+1):
    a = input().split(" ")
    s.append(a)

count = 0
for j in range(len(s)-1):
    if s[j][0] == s[j][1]:
        if s[j+1][0] == s[j+1][1]:
            count += 1
            if count >= 2:
                print("Yes")
                break
        else:
            count -= 1


if count < 2:
    print("No")
n = int(input())
data = []
zoro = []
yn = False
for i in range(n):
    data = input().split()
    if data[0] == data[1]:
        zoro += [True]
    else:
        zoro += [False]
    if i > 1 and (zoro[i] == True or zoro[i-1] == True or zoro[i-2] == True):
        yn = True
print(zoro)
print("Yes") if yn == True else print("No")
#!/usr/bin/env python3
N = int(input()) 

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

print(result)
N = int(input())
lst = []
for _ in range(N):
  d1, d2 = map(int, input().split(' '))
  lst.append((d1, d2))
  
idx = 0
flag = False
while idx < N-2:
  cnt = 0
  for _ in range(3):
    d1, d2 = lst[idx]
    if d1 == d2:
      cnt += 1
  if cnt == 3:
    flag = True
    break
  else:
    idx += 1

print('Yes' if flag else 'No')
N = int(input())
flag = 0
ans = "No"
for i in range(N):
  A,B = input().split()
  if flag == 3:
    ans = "Yes"
    break
  if A == B:    
    flag += 1
  else:
    flag = 0
    
print(ans)
n = int(input())
a_lst = []
b_lst = []
clear = 0
cnt = 0
for i in range(n):
  a, b = map(int, input().split())
  a_lst.append(a)
  b_lst.append(b)

for a, b in zip(a_lst, b_lst):
  if cnt == 3:
    clear = 1
    break
  if a == b:
    cnt += 1
  else:
    cnt = 0

if clear == 1:
  print('Yes')
else:
  print('No')
n =int(input())
first =[]
second =[]
for i  in range(n):
    d1 , d2 = map(int , input().split())
    first.append(d1)
    second.append(d2)

for i in range(n-2):
    count = 0
    for j in range(i ,i+3):
        if first[j]==second[j]:
            count +=1
           
    if count ==3:
        print("YES")
        break
else:
    print("NO")
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)
if(n<3):
    print('NO')
else:
    
    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')
N = int(input())
occur = 0
for i in range(0,N):
    D1,D2 = map(int,input().split())
    if D1 == D2:
        occur +=1
if occur == N:
    print("Yes")
elif occur > 3:
    print("No")
else:
    print("Yes")
N = int(input())

flag = False

d1 = [0]*N
d2 = [0]*N
for i in range(N-1):
  d1[i], d2[i] = input().split()
  
for k in range(N-3):
  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')
N = int(input())
z = 0
f = False
for i in range(N):
    r = list(map(int, input().split()))
    if r[0] == r[1]:
        z += 1
        if z == 2:
            f = True
    elif not f:
        f = False
        z = 0
if f:
    print("Yes")
else:
    print("No")
num=int(input())
re=0
res=0
for i in range(num):
    a=input().split(" ")
    if a[0]==a[1]:
        re +=1
        if re>=3:
            res=1
    else:
        re=0

if(re<3):
    print("No")
else:
    print("Yes")
N = int(input())
flag = 0
ans = "No"
for i in range(N):
  A,B = input().split()
  if A == B:    
    flag += 1
  if flag == 3:
    ans = "Yes"
    break
  else:
    flag = 0
    
  
print(ans)
n = int(input())
num_of_double = 0

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

    if d1 == d2:
        num_of_double += 1

if num_of_double >= 3:
    print("Yes")
else:
    print("No")
n=int(input())
c=[]
for i in range(n):
  a,b=map(int,input().split())
  if a==b:
    c.append(1)
  else:
    c.append(0)
for j in range(2,n):
  if c[j-2]==c[j-1] and c[j-1]==c[j]:
      print("Yes")
      break
  if j==n-1:
      print("No")
print('NYoe s'['111'in''.join(str(len({*t.split()}))for t in open(0))::2])
import sys

n = int(input())

zoro = 0
res = 0

for i in range(n):
    d1, d2 = map(int, input().split())
    if zoro == 3:
        res = 1
    elif d1 == d2:
        zoro = zoro + 1
    else:
        zoro = 0

if res == 1:
    print("Yes")
else:
    print("No")
n=int(input())
l=[]
m=[]
for i in range(0,n):
  a,b=map(int,input().split())
  l.append(a)
  m.append(b)
c=0
for i in range(0,n):
  if l[i]==m[i]:
    c=c+1
  else:
    c=0
if c==3:
  print('Yes')
else:
  print('No')
class Main:
    n = int(input())
    num_list =[]
    count = 0
    for i in range(n):
        num_list.append(list(map(int,input().split())))

    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]:
            count +=1

    if count == 1:
        print('Yes')
    else :
        print('No')
i = int(input())
d = [list(map(int, input().split())) for i in range(i)]

c = 0
for i in range(len(d)):
    if (d[i][0] == d[i][1]):
        c += 1
print("Yes" if c >= 3 else "No")
n = int(input())
d = [list(map(int, input().split())) for _ in range(n)]

exist = False
for i in range(n-3):
    for j in range(3):
        if not d[i+j][0] == d[i+j][1]:
            break
    else:
        exist = True
if exist:
    print('Yes')
else:
    print('No')
def solution(arr):
  count = 0
  for i, j in arr:
    if i == j:
      count += 1
    else:
      count = 0
    if count == 2:
      return 'Yes'
  return 'No'
n = int(input())
arr = []
for _ in range(n):
  arr.append([ int(i) for i in input().split()])
print(solution(arr))
def func():
    count = 0
    for _ in range(N):
        if count == 3:
            return "Yes"
        a, b = map(int, input().split())
        if a == b:
            count += 1
        else:
            count = 0
    return "No"


N = int(input())

print(func())
b = []
a = int(input())
for i in range(a):
	b.append(list(map(int,input().split())))
c = []
for i in range(a):
    if b[i][0] == b[i][1]:
        c.append(1)
    elif b[i][0] != b[i][1]:
        c.append(0)
for i in range(2, a-2):
    if c[i] == 1 & c[i-1] == 1 & c[i+1] == 1:
        print('Yes')
n=int(input())
ans=0
D=[]
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

if ans>=3:
  print("Yes")
  
else:
  print("No")
N = int(input())
S = []
judge = 0
for i in range(N):
    S += [input().split()]
for i in range(N):
    if i <= N-i:
        if S[i][0] == S[i][1]:
            if S[i+1][0] == S[i+1][1]:
                if S[i+2][0] == S[i+2][1]:
                    print("Yes")
                    judge = 1
                    break
if judge == 0:
    print("No")
n=int(input())
a=[]
for i in range(n):
    x,y=map(int,input().split())
    a.append((x,y))
ok=False
for i in range(n-3):
    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]:
        ok=True
if ok==True:
    print("Yes")
else:
    print("No")
n = int(input())
cnt = 0
is_ok = False
for _ in range(n):
    d1, d2 = map(int, input().split())
    if d1 == d2:
        cnt += 1
    else:
        cnt = 1
    if cnt >= 3:
        is_ok = True
    else:
        pass
if is_ok:
    print('Yes')
else:
    print('No')
n = int(input())
d = [list(map(int,input().split())) for i in range(n)]
ans = "No"
for i in range(n-3):
    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()
for i in range(n):
    d.append(list(map(int,input().split())))

an=1
for i in range(n):
    if n > i+3:
        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]:
            an=0
            break
if an==0:
    print('Yes')
else:
    print('No')
N = int(input())
l = [list(map(int, input().split())) for l in range(N)]

last = 0
for item in l:
  if last == 0 and l[0] == l[1]:
    last = 1
  elif last == 1 and l[0] == l[1]:
    last = 2
  elif last == 2 and l[0] == l[1]:
    last = 3
    break
  last == 0

if last == 3:
  print('Yes')
else:
  print('No')
def main():
    n = int(input())
    cnt = 0
    for i in range(n):
        a,b = map(int,input().split())
        if cnt == 3:
            print('Yes')
            return
        if a == b:
            cnt += 1
        else:
            cnt = 0
    print('No')
    return

main()
N=int(input())
D1 = [0] * N
D2 = [0] * N
for i in range(N):
    D1[i], D2[i]= map(int, input().split())
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]:
                print("Yes")
                break
        else:
            print("No")
n = int(input())

num_list=[]
count=0

for i in range(n):
    a,b = map(int, input().split())
    if a==b:
        count+=1
    if a!=b:
        if count<3:
            count=0
if count>2:
    print('YES')
else:
    print('NO')
n = int(input())

count = 0
ans = 0
for i in range(n):
    s = input().split()
    
    if s[0]==s[1]:
        count += 1
        
        if count >= 3:
            ans = 1
if ans == 1:
    print('Yes')
else:
    print('No')
n = int(input())
i = 0
for _ in range(n):
    x, y = map(int, input().split())
    i += int(x == y)
    if i == 3:
        print("Yes")
        break
if(i < 3):
    print("No")
N = int(input())

count = 0

for i in range(N):
    k, t = map(int, input().split())
    if count == 3:
      print ( "yes" )
     
      break
      
    if not k == t:
        count *= 0
    if k == t:
       count += 1 
if not count == 3:
        print ("no")
def solution(arr):
  count = 0
  for i, val in enumerate(arr):
    if arr[i - 1] == val:
      count += 1
    else:
      count = 0
    if count == 2:
      return 'Yes'
  return 'No'
n = int(input())
arr = []
for _ in range(n):
  arr.append(input())
print(solution(arr))
N = int(input())
count = 0
list1 = []
list2 = []
for i in range(N-1):
    a, b = list(map(int, input().split()))
    list1.append(a)
    list2.append(b)
    
for i in range(N-1):
  if list1[i] == list2[i]:
    count += 1
    if count >= 3:
      break
  else:
    count = 0
if count >= 3:
  print("Yes")
else:  
  print("No")
n = int(input())
flag = 0
for i in range(n):
    n1, n2 = map(int, input().split())
    if n1 == n2:
        flag += 1
        if flag == 3:
            print("Yse")
            break
    else:
        flag = 0
print("No")
import random

exit = False

count = 0

countNum = 0

randomArray1 = random.randint(1,6)
randomArray2 = random.randint(1,6)

while count < 4:

    randomArray1 = random.randint(1,6)
    randomArray2 = random.randint(1,6)

    print(randomArray1,randomArray2)

    countNum += 1

    if randomArray1 == randomArray2:
        count += 1


print(countNum)
print("END")
N = int(input())
j = 0
if N >= 3:
    for i in range(0, N):
        D = str(input())
        D = D[0::2]
        if D[0] == D[1]:
            j += 1
    if j == 3:
        print("Yes")
    elif j == 6:
        print("Yes")
    elif j != 3:
        print("No")
    else:
        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")
else:
  print("No")