peterverebics/CodeNet_Python_118 huggingface dataset:
N = int(input())
listD = []
for i in range(N):
  listD.append(list(map(int,input().split()))	)

  
###################################################
count = 0
flag = False
for j in range(N):
  if listD[j][0] == listD[j][1]:
    count += 1
    if count >= 3:
      print("Yes")
      flag = True
      break
  else:
    count = 0
if flag == False:
  print("No")
N = int(input())
D1, D2 = [], []
for i in range(N):
  li = list(map(int,input().split()))
  D1.append(li[0])
  D2.append(li[1])

D = ""

for i in range(N):
  if D1[i]==D2[i]:
    D += 'T'
  else:
    D += 'F'

if 'TTT' in D:
  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())
f = 0
for k in range(N):
    A, B = map(int,input().split())
    if A == B:
        f += 1
        if f == 3:
            print("Yes")
            exit(0)
    else:
        f = 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:
        if max_count < count:
            max_count = count
        count = 0

if max_count < count:
    max_count = count

if max_count >= 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
    else:
        count = 0
    if count >= 3:
        flag = True

if flag:
    print("Yes")
else:
    print("No")
n=int(input())
counter=0
flag=0
for i in range(n):
    a,b=input().split()
    if(a==b):
        counter=counter+1
    else:
        counter=0
    if(counter>2):
        flag=1
if(flag==1):
    print('Yes')
else:
    print('No')
X=int(input())
cnt=0
for i in range(X):
    A,B=list(map(int,input().split()))
    if A==B:
        cnt=cnt+1
    else:
        cnt=0
    if cnt==3:
        print('Yes')
        exit()
print('No')
n=int(input())
flag=False
count=0
for i in range(n):
    u,v=map(int,input().split())
    if u==v:
        count+=1
        if count==3:
            flag=True

    else:
        count=0
if flag==True:
    print('Yes')
else:
    print('No')
n = int(input())
c = 0
f = False
for i in range(n):
    x,y = map(int,input().split())
    if x==y:
        c += 1
    else:
        if c>=3:
            f = True
        c = 0
if c>=3:
    f = True
print('Yes' if f else 'No')
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")
n = int(input())
count = 0
ans = 'No'
for i in range(n):
  a,b = map(int, input().split())
  if a == b:
    count += 1
  else:
    count = 0
  if count >= 3:
    ans = 'Yes'
    break
print(ans)
N = int(input())
ans = "No"
tmp = 0
for i in range(N):
    d1, d2 = map(int, input().split())
    if d1 == d2:
        tmp += 1
        if tmp == 3:
            ans = "Yes"
            break
    else:
        tmp = 0
print(ans)
n = int(input())

count = 0

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

    if a == b:
        count += 1

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

if count >= 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))
ans = "No"
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]:
        ans = "Yes"
print(ans)
n=input()
cc=0
ok=1
for i in range(n):
    a,b=map(int,raw_input().split()) 
    if a==b: 
        cc+=1 
    else: 
        cc=0
    if cc==3: 
        print "Yes";ok=0;break
if ok: 
    print "No"
N = int(input())
D = []
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:
    break

if count >= 3:
  print('Yes')
else:
  print('No')
N=int(input())
check=0
Flag=False
for i in range(N):
    d_1,d_2=map(int,input().split())
    if d_1==d_2:
        check+=1
    else:
        check=0
    if check==3:
        Flag=True
if Flag:
    print('Yes')
else:
    print('No')
N, = map(int, input().split())
c = 0
for _ in range(N):
    a, b = map(int, input().split())
    if a == b:
        c += 1
    else:
        c = 0
    if c == 3:
        print("Yes")
        break
else:
    print("No")
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()

a = 0
for i in range(n):
    d,dd = na()
    if d == dd:
        a += 1
    else:
        a = 0
    if a >= 3:
        print('Yes')
        exit()

print('No')
N = int(input())
cnt = 0
for n in range(N):
    d1, d2 = map(int, input().split())
    if d1 == d2:
        cnt += 1
        if cnt == 3:
            print('Yes')
            break
    else:
        cnt = 0
else:
    print('No')
N=int(input())
D={}
for i in range(N):
    D[i]=input().split()

cou=0
for i in range(N):
    if D[i][0]==D[i][1]:
        cou+=1
        if cou ==3:
            print('Yes')
            break
    else:
        cou=0

if cou < 3:
    print('No')
import sys
N = int(input())
K = []
for i in range(N):
    a, b = map(int, input().split())
    K.append([a, b])
for i in range(N-2):
    if K[i][0] == K[i][1] and K[i+1][0] == K[i+1][1] and K[i+2][0] == K[i+2][1]:
        print("Yes")
        sys.exit()
print("No")
n = int(input())
cnt = 0
for _ in range(n):
  a,b = map(int, input().split())
  if a==b:
    cnt+=1
    if cnt==3:
      break
  else: cnt = 0
if cnt==3: print('Yes')
else: print('No')
def main():
    n = int(input())
    
    l = []
    for _ in range(n):
        d1,d2 = tuple(map(int,input().split()))
        l.append(1 if d1==d2 else 0)

    for i in range(n-2):
        if sum(l[i:i+3])==3:
            print("Yes")
            return

    print("No")
    

if __name__ == "__main__":
    main()
n = int(input())
cnt = 0
isOK = False
for i in range(n):
  x,y = map(int,input().split())
  if x==y:
    cnt += 1
  else:
    cnt = 0
  if cnt>=3:
    isOK = True
    break
#if cnt >= 3:
#  isOK = True

if isOK:
  print('Yes')
else:
  print('No')
def solve():
    n = int(input())
    rolls = [list(map(int,input().split())) for i in range(n)]
    for i in range(n-2):
        if rolls[i][0]==rolls[i][1] and rolls[i+1][0]==rolls[i+1][1] and rolls[i+2][0]==rolls[i+2][1]:
                return True

    return False

print("Yes" if solve() else "No")
N=int(input())
count=0
result="No"
for n in range(N):
  d=list(map(int,input().split()))
  if (d[0]==d[1]):
    count+=1
    if count==3:
      result="Yes"
  else:
    count=0
print(result)
n = int(input())
str_list = [list(input().split()) for _ in range(n)]
ans = 0
for i in range(n-2):
    if str_list[i][0] == str_list[i][1]:
        if str_list[i+1][0] == str_list[i+1][1]:
            if str_list[i+2][0] == str_list[i+2][1]:
                ans += 1
    
if ans:
    print('Yes')
else:
    print('No')
N = int(input())
k = 0

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

for i in range(N):
    if x[i] == y[i]:
        k += 1
    else:
        k = 0
    if k == 3:
        break

if k == 3:
    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())
cnt=0
flg=0

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

if flg:
    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:
        if count >= 3:
            print("Yes")
            exit()
        count = 0
if count >= 3:
    print("Yes")
else:
    print("No")
import sys
input = sys.stdin.readline

n = int(input())
dice = []

for _ in range(n):
    d_1, d_2 = map(int,input().split())
    dice.append([d_1, d_2])

ans = 0

for i in range(n-2):
    if dice[i][0] == dice[i][1]:
        if dice[i+1][0] == dice[i+1][1] and dice[i+2][0] == dice[i+2][1]:
            ans = 1
            break
        else:
            continue
        break

if ans > 0:
    print("Yes")
else:
    print("No")
import sys
N = int(input())

z = [0 for _ in range(N)]
tmp = 0
for i in range(N):
  d1, d2 = map(int,input().split())
  if d1 == d2:
    tmp += 1
  else:
    tmp = 0
  if tmp >= 3:
    print("Yes")
    sys.exit()
    
print("No")
n = int(input())
counter = 0
for i in range(n):
    d1, d2 = map(int, input().split())
    if d1 == d2:
        counter += 1
    else:
        counter = 0
    if counter >= 3:
        print("Yes")
        break
else:
    print("No")
n = int(input())
d = [list(map(int, input().split())) for i in range(n)]
ok = False
for i in range(n-2):
    if d[i][1] == d[i][0]:
        if d[i+1][1] == d[i+1][0]:
            if d[i+2][1] == d[i+2][0]:
                ok = True
if ok == True:
    print("Yes")
else:
    print("No")
N = int(input())
tmp = 0
ans = False

for i in range(N):
    tmp += 1
    t = tuple(map(int, input().split()))
    if t[0] != t[1]:
        tmp = 0
    if tmp >= 3:
        ans = True

print('Yes' if ans else 'No')
def main():
    n = int(input())

    count = 0
    answer = 'No'
    for i in range(n):
        d = list(map(int, input().split()))
        if d[0] == d[1]:
            count += 1
        else:
            count = 0
        if count >= 3:
            answer = 'Yes'

    print(answer)


if __name__ == '__main__':
    main()
counter = int(input())
result_flg = False

fir_fir, fir_sec = map(int, input().split())
sec_fir, sec_sec = map(int, input().split())


for i in range(2, counter):
  thi_fir, thi_sec = map(int, input().split())

  if fir_fir == fir_sec:
    if sec_fir == sec_sec:
      if thi_fir == thi_sec:
        result_flg = True
        break

  # reset content
  fir_fir = sec_fir
  fir_sec = sec_sec
  sec_fir = thi_fir
  sec_sec = thi_sec

if result_flg == True:
  print('Yes')
else:
  print('No')
x=[]
for i in range(int(input())):
    a,b=map(int,input().split())
    x.append([a,b])
    an=0
for j in range(len(x)-2):
    if x[j][0]==x[j][1] and x[j+1][1] == x[j+1][0] and x[j+2][1] == x[j+2][0]:
        an=1
if an:
    print("Yes")
else:
    print("No")
n = int(input())
d = [list(map(int, input().split())) for _ in range(n)]
cnt = 0
ans = False
for i in range(n):
    if d[i][0] == d[i][1]:
        cnt += 1
        if cnt >= 3:
            ans = True
            print('Yes')
            exit()
    else:
        cnt = 0
print('No')
n = int(input())
data = [list(map(int, input().split())) for i in range(n)]
cnt = 0
for i in range(1, n-1):
    if data[i][0] == data[i][1] and data[i-1][0] == data[i-1][1] and data[i+1][0] == data[i+1][1]:
        print("Yes")
        exit()

print("No")
N = int(input())
cur = 0
ok = False
for _ in range(N):
    D1, D2 = input().split()
    if D1 == D2:
        cur += 1
    else:
        cur = 0
    if cur == 3:
        ok = True
if ok:
    print('Yes')
else:
    print('No')
N=int(input())
D=list()
for i in range(0,N):
    a,b=map(int,input().split())
    D.append((a,b))
a = ''
for i in range(0,N):
    if D[i][0]==D[i][1]:
        a=a+'1'
    else:
        a=a+'0'
if '111' in a:
    print('Yes')
else:
    print('No')
N = int(input())
D = [list(map(int, input().split())) for _ 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'
    break
    
print(ans)
n = int(input())
ans = 0
last = 0
for i in range(n):
  d1, d2 = map(int,input().split())
  if d1 == d2:
    ans += 1
  else:
    last = max(last,ans)
    ans = 0
last = max(last,ans)
if last > 2:
  print('Yes')
else:
  print('No')
n=int(input())
ct=0
best=0
arr=[]
for i in range(n):
	a,b=map(int,input().split())
	if a==b:
		ct+=1
		best=max(ct,best)
	else:
		ct=0
if best>=3:
	print("Yes")
else:
	print("No")
def main():
    N = int(input())
    cnt = 0
    flag = False
    for _ in range(N):
        D1, D2 = map(int, input().split())
        if D1 == D2:
            cnt += 1
        else:
            cnt = 0
        if cnt == 3:
            flag = True
    if flag:
        print('Yes')
    else:
        print('No')



if __name__ == "__main__":
    main()
n = int(input())
flag = 0
out = False
for j in range(n):
    ins = input().split()
    if(ins[0]==ins[1]):
        flag+=1
        if(flag==3):
            out=True
    else:
        flag = 0
if(out):
    print("Yes")
else:
    print("No")
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")
    exit()
print("No")
n = int(input())
d = []
for i in range(n):
  t = [int(x) for x in input().split()]
  d.append(t)

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())
D = [list(map(int, input().split())) for i 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]:
        if D[i+2][0] == D[i+2][1]:
            flag = 1
if flag == 1:
    print('Yes')
else:
    print('No')
n=int(input())
ans='No'
tmp=0
for i in range(n):
    a,b=map(int,input().split())
    if a==b:
        tmp+=1
    else:
        tmp=0
    if tmp==3:
        ans='Yes'
print(ans)
N=int(input())
x=0
a=0
for i in range(N):
    A,B=map(int,input().split())
    if A==B:
        x+=1
    else:
        x=0
    if x==3:
        a=1
if a==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
        if count == 3:
            print("Yes")
            exit()
    else:
        count = 0

print("No")
def MI():
    return map(int, input().split())

n = int(input())

cnt=[0]*(n+1)
for i in range(n):
    a,b= MI()
    if a==b:
        cnt[i+1]=cnt[i]+1
    else:
        cnt[i+1]=0

if max(cnt)>2:
    print('Yes')
else:
    print('No')
n=int(input())
count=0
lists=[]
for i in range(n):
    d1,d2=list(map(int,input().split()))
    lists.append([d1,d2])
for i in range(n-2):
    if lists[i][0]==lists[i][1] and lists[i+1][0]==lists[i+1][1] and lists[i+2][0]==lists[i+2][1]:
        print('Yes')
        break
    elif i==n-3:
        print('No')
        break
    else:
        continue
n = int(input())
d = [0]*n

for i in range(n):
  d[i] = input().split()
  
c = 0

for i in range(n):
  #print(c)
  if d[i][0] == d[i][1]:
    c += 1
    if c == 3:
      print("Yes")
      exit()
  else:
    c = 0

print("No")
n = int(input())
zo=[False]*n
for i in range(n):
  a,b = map(int,input().split())
  if a==b:
    zo[i] = True
for i in range(n-2):
  if zo[i] and zo[i+1] and zo[i+2]:
    print("Yes");exit()
print("No")
N = int(input()) 
ans = 'No' 
cnt = 0 
for _ in range(N): 
    x, y = map(int, input().split()) 
    if x == y: 
        cnt += 1 
        if cnt == 3: 
            ans = 'Yes' 
    else:
        cnt = 0
print(ans)
N = int(input())
MAX = 0
cnt = 0
for _ in range(N):
    d1, d2 = map(int,input().split())
    if d1 == d2:
        cnt += 1
        MAX = max(MAX, cnt)
    else:
        cnt = 0
if MAX >= 3:
    print('Yes')
else:
    print('No')
n = int(input())
d = [list(map(int,input().split())) for i in range(n)]
count = 0

# [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6]]

for i in d:
  if i[0] == i[1]:
    count += 1
  else:
    count = 0
  if count == 3:
    print('Yes')
    exit()
print('No')
N = int(input())
li = list()
for i in range(N):
    a, b = [int(x) for x in input().split()]
    li.append([a,b])

count = 0
for i in li:
    if count < 3:
        if i[0] == i[1]:
            count += 1
        else:
            count = 0
    else:
        break

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

cnt,cnt_max = 0,0
for i in range(N):
    if D[i][0] == D[i][1]:
        cnt += 1
    else:
        cnt = 0
    cnt_max = max(cnt,cnt_max)

if cnt_max >= 3:
    print("Yes")
else:
    print("No")
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")
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
print("No")
N = int(input())
cnt = 0
ans = "No"
for i in range(N):
    D = list(map(int, input().split()))
    if D[0] == D[1]:
        cnt += 1
        if cnt >= 3:
            ans = "Yes"
            continue
    else:
        cnt = 0
print(ans)
def main():
    N = int(input())
    D = []
    for _ in range(N):
        a, b = (int(i) for i in input().split())
        D.append(int(a == b))

    if any(sum(D[i:i+3]) == 3 for i in range(N-3+1)):
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()
n=int(input())
x=[list(map(int,input().split()))for i in range(n)]
#print(x)

for i in range(n-2):
  cnt = 0
  if  x[i][0]==x[i][1]:
    cnt=1
  else:
    continue
    
  if  x[i+1][0]==x[i+1][1]:
    cnt=cnt+1
    
  else:
    continue
    
  if x[i+2][0]==x[i+2][1]:
    cnt=cnt+1 
    if cnt==3:
      print('Yes')
      break
  else:
    break
if cnt!=3:
  print('No')
n = int(input())
d_l = [ list(map(int, input().split())) for _ in range(n)  ]

ans = 'No'
z = 0
for i, j in d_l:
    if i == j:
        z+=1
    else:
        z=0
    if z == 3:
        ans = 'Yes'
        break
print(ans)
N = int(input(""))
L = [0 for i in range(N)]
flag = False

for i in range(N):
    a, b = input().strip().split()
    a, b = [int(a), int(b)]
    L[i] = a - b
for i in range(N - 2):
    if (L[i] == 0 and L[i+1] == 0 and L[i+2] == 0):
        flag = True

if flag:
    print("Yes")
else:
    print("No")
n = int(input())
arr = []
for i in range(n):
  x, y = map(int, input().split())
  arr += [[x, y]]

flag = 0
for i in range(1, n-1):
  if arr[i-1][0] == arr[i-1][1] and arr[i][0] == arr[i][1] and arr[i+1][0] == arr[i+1][1]:
    flag = 1
    break
if flag == 1:
  print("Yes")
else:
  print("No")
n = int(input())
tmp = 0
import sys
for i in range(n):
    d = list(map(int,input().split()))
    if d[0] == d[1]:
        tmp += 1
        #check
        if tmp == 3:
            print('Yes')
            sys.exit()
    else:
        tmp = 0
print('No')
n = int(input())
t = [0] * n
x = [0] * n
for i in range(n):
    t[i], x[i] = map(int, input().split())
a=0
for j in range(n-2):
    if t[j]==x[j]and t[j+1]==x[j+1] and t[j+2]==x[j+2]:
        a+=1
    else:
        a+=0
if a==0:
    print('No')
else:
    print('Yes')
n = input()
n = int(n)
d = []
for i in range(n):
    d.append(input().split())
active = False
count = 0
for x in d:
    if x[0] == x[1]:
        active = True
        count += 1
    else:
        count = 0
        active = False
    if count >2:
        break
if count > 2:
    print("Yes")
else:
    print("No")
N=int(input())
T=False
k=0
for i in range(N):
    D1,D2=map(int,input().split())
    if D1==D2:
        k+=1
        if k>=3:
            T=True
    else:
        k=0
if T:
    print("Yes")
else:
    print("No")
import math
import fractions
import collections
import itertools
N=int(input())
l=[]
for i in range(N):
    x,y=map(int,input().split())
    if x==y:
        l.append(1)
    else:
        l.append(0)
flag=0
#print(l)
for i in range(N-2):
    num=l[i]+l[i+1]+l[i+2]
    #print(i,i+1,i+2)
    if num==3:
        flag=1
        break
if flag==1:
    print("Yes")
else:
    print("No")
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 = 0

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

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

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

cnt = 0
ans = False
for a, b in D:
  if a == b:
    cnt += 1
  else:
    cnt = 0
  if cnt == 3:
    ans = True

if ans:
  print("Yes")
else:
  print("No")
N = int(input())
D = [list(map(int, input().split())) for _ in range(N)]
for d1, d2, d3 in zip(D, D[1:], D[2:]):
    if d1[0] == d1[1] and d2[0] == d2[1] and d3[0] == d3[1]:
        print("Yes")
        exit()
print("No")
N = int(input())
d_ls=[]
for vakawkawelkn in range(N):
	D1,D2=map(int, input().split())
	if D1==D2:
		d_ls+=[1]
	else:
		d_ls+=[0]

flag=0
for i in range(N-2):
	if d_ls[i]*d_ls[i+1]*d_ls[i+2]==1:
		flag=1


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


# 2darray [[0] * 4 for i in range(3)]
# import itertools
def main():
    n = int(input())
    d =[]
    cnt = 0
    ans = 'No'
    for i in range(n):
        d1 = list(map(int,input().split()))
        if d1[0] == d1[1]:
            cnt += 1
        else:
            cnt = 0
        if cnt == 3:
            ans = 'Yes'
        d.append(d1)
    print(ans)

if __name__=='__main__':
    main()
N = int(input())
L = []
t = 0
for i in range(N):
    D = [int(i) for i in input().split()]
    if D[0] == D[1]:
        L.append(i)
        if len(L) >= 3:
            if L[-2] == i-1 and L[-3] == i-2:
                print('Yes')
                t = 1
                break

if t == 0:
    print('No')
n = int(input())
d = [list(map(int,input().split())) for i in range(n)]
cnt=[]
ans=0
for a in range(n):
  if d[a][0]==d[a][1]:
    cnt.append(1)
    if a>1:
      if cnt[a-2]==cnt[a-1]==cnt[a]:
        ans+=1
  else:
    cnt.append(0)

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

d  = []
for i in range(N):
    D1, D2 = map(int, input().split())
    if D1 == D2:
        ans = "same"
    else:
        ans = "different"
    d.append(ans)
flag = "No"
for i in range(N-2):
    if d[i] == "same" and d[i+1] == "same" and d[i+2] == "same":
        flag = "Yes"
print(flag)
N = int(input())

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

print("No")
N = int(input())
D1 = []
D2 = []

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

for i in range(N-2):
  if D1[i:i+3] == D2[i:i+3]:
    print("Yes")
    exit()

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

a = 0
for i in range(n):
    li = input().split()
    if(li[0]==li[1]):
        a+=1
    elif(a<3):
        a=0
    else:
        print("Yes")
        exit()
if(a>2):
    print("Yes")
    exit()

print("No")
n = int(input())
renz = 0
for i in range(n):
    d1,d2 = map(int,input().split())
    if d1 == d2:
        renz += 1
        if renz == 3:
            break
    else:
        renz = 0
if renz == 3:
    print('Yes')
else:
    print('No')