peterverebics/CodeNet_Python_118 huggingface dataset:
n = int(input())
d_1 = []
d_2 = []

for i in range(n):
        a = list(map(int, input().split()))
        d_1.append(a[0])
        d_2.append(a[1])

for i in range(n-2):
        if d_1[i] == d_2[i] and d_1[i+1] == d_2[i+1] and d_1[i+2] == d_2[i+2]:
                print("Yes")
                exit()

print("No")
n = int(input())
d_lst = [list(map(int, input().split())) for _ in range(n)]

flag = False
count = 0
for i in range(n):
    d1 = d_lst[i][0]
    d2 = d_lst[i][1]

    if d1 == d2:
        count += 1

        if count == 3:
            flag = True

    else:
        count = 0

if flag:
    print('Yes')
else:
    print('No')
def main():
    count=0
    n=int(input())
    x = [list(map(int, input().split())) for i in range(n)]
    for i in range(n):
        if x[i][0]==x[i][1]:
            count=count+1
        else:
            count=0

        if count==3:
            print("Yes")
            break


    if count!=3:
        print("No")





if __name__ == '__main__':
    main()
def func():
    count = 0
    for _ in range(N):
        a, b = map(int, input().split())
        if a == b:
            count += 1
        else:
            count = 0
        if count >= 3:
            return "Yes"
    return "No"


N = int(input())

print(func())
n = int(input())
d = []
for _ in range(n):
    d.append(list(map(int, input().split())))

cnt = 0
for i in d:
    if i[0] == i[1]:
        cnt += 1
    else:
        cnt = 0
    if cnt >= 3:
        print('Yes')
        exit()

print('No')
n = int(input())
d = [input().split(" ") for _ in range(n)]

f = False
for i in range(n-2):
    if d[i][0] == d[i][1] and not f :
        if d[i+1][0] == d[i+1][1] and d[i+2][0] == d[i+2][1]:
            f = True
if f:
    print("Yes")
else:
    print("No")
N = int(input())
dice = [tuple(map(int, input().split())) for _ in range(N)]
count = 0
for d1, d2 in dice:
    if d1 != d2:
        count = 0
        continue
    else:
        count += 1
    if count == 3:
        print('Yes')
        break
else:
    print('No')
n=int(input())
ans=0
c=True
d=[]
for i in range(n):
    a,b=map(int,input().split())
    if a==b:
        d.append(i)
if len(d)<3:
    print("No")
else:
    j=0
    for i in range(1,len(d)-1):

        if d[i]-d[i-1]==1 and d[i+1]-d[i]==1:
            print("Yes")
            c=False
            break

    if c==True:
        print("No")
n = int(input())
m = 0
s = "No"
for i in range(n):
  a,b = map(int, input().split())
  if a == b:
    m += 1
  if m == 3:
    s = "Yes"
    break
  elif a != b:
    m = 0
print(s)
N = int(input())
D = [list(map(int, input().split())) for _ in range(N)]

for i, j, k in zip(range(N), range(1, N), range(2, N)):
    if D[i][0] == D[i][1] and D[j][0] == D[j][1] and D[k][0] == D[k][1]:
        print('Yes')
        exit()
print('No')
n = int(input())
flag = 0
max_ = 0
for i in range(n):
    d = list(map(int, input().split()))
    if d[0] == d[1]:
        flag += 1
    else:
        flag = 0

    if max_ < flag:
        max_ = flag

if max_ >= 3:
    print("Yes")
else:
    print("No")
def main():
    n = int(input())
    count = 0
    for _ in range(n):
        a, b = [int(x) for x in input().split()]
        if a == b:
            count += 1
        else:
            count = 0

        if count >= 3:
            return 'Yes'
    return 'No'


if __name__ == '__main__':
    print(main())
N = int(input())
l = []
for _ in range(N):
    a, b = map(int, input().split())
    l.append((a, b))

cnt = 0
for t in l:
    if t[0] == t[1]:
        cnt += 1
        if cnt >= 3:
            break
    else:
        cnt = 0
if cnt >= 3:
    print('Yes')
else:
    print('No')
n=int(input())
m=0
l=0
for i in range(n):
  A,B=map(int,input().split())
  if (A==B):
    m+=1
  else:
    m=0
  if (m==3):
    print("Yes")
    l=1
    break

if (l==0):
  print("No")
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())
ans1 = False
ans2 = False
ans3 = False
for i in range(N):
  D1, D2 = map(int, input().split())
  if D1 == D2 and ans1 == False:
    ans1 = True
  elif D1 == D2 and ans1 == True and ans2 == False:
    ans2 = True
  elif D1 == D2 and ans1 == True and ans2 == True and ans3 == False:
    ans3 = True
    print("Yes")
    exit()
  elif D1 != D2:
    ans1 = False
    ans2 = False
    ans3 = False
print("No")
N = int(input())
list_D = [list(map(int, input().split())) for i in range(N)]

count = 0
for i in range(N-2):
  if list_D[N-i-1][0] == list_D[N-i-1][1] and list_D[N-i-2][0] == list_D[N-i-2][1] and list_D[N-i-3][0] == list_D[N-i-3][1]:
    count += 1
if count > 0:
  print('Yes')
else:
  print('No')
n = int(input().strip())
count = 0
for i in range(n):
  a,b = map(int,input().strip().split())
  if count == 3:
    print('Yes')
    exit(0)
  elif a == b:
    count += 1
  elif(a != b):
    count = 0
if count == 3:
	print('Yes')
else:
	print('No')
N = int(input())

count = 0
for _ in range(N):
  D = map(int, input().split())
  D = list(D)
  if D[0] == D[1]:
    count += 1
    if count >= 3:
      print('Yes')
      break
    continue
  count = 0
else:
  print('No')
s = int(input())
count = 0

for i in range(s):
  dice1, dice2 = map(int, input().split())
  if dice1 == dice2:
    count += 1
    if count >= 3:
      print("Yes")
      break
  else:
    count = 0
else:
  print("No")
# -*- coding: utf-8 -*-
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:
        break

print("Yes" if counter == 3 else "No")
N = int(input())
D = [[0 for j in range(2)] for i in range(N)]
c, t = 0, 0

for i in range(N):
    D[i][0], D[i][1] = map(int, input().split())
    if D[i][0] == D[i][1]:
        c += 1
    else:
        c = 0
    if c == 3:
        t = 1
if t == 1:
    print('Yes')
else:
    print('No')
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:
        print("Yes")
        break
else:
    print("No")
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')
        exit(0)
        
print('No')
N = int(input())
cnt = 0
ans = 'No'
for i in range(N):
    x,y = [int(x) for x in input().split()]
    if x == y:
        cnt += 1
        if cnt == 3:
            ans = 'Yes'
    else:
        cnt = 0
        

print(ans)
# coding: utf-8
# Your code here!
import sys
readline = sys.stdin.readline
read = sys.stdin.read

#n,q = map(int, readline().split())
#*a, = map(int, readline().split())

n = int(input())

cnt = 0
for i in range(n):
    a,b = map(int, readline().split())
    if a==b:
        cnt += 1
    else:
        cnt = 0
    if cnt == 3:
        print("Yes")
        break
else:
    print("No")
n = int(input())
lis = [list(map(int,input().split())) for _ in range(n)]

cnt = 0
flg = 0

for i in lis:
    if i[0]==i[1]:
        cnt += 1
        if cnt >= 3:
            flg = 1
    else:
        cnt = 0

if flg == 1:
    print('Yes')
else:
    print('No')
N=int(input())

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

    if count==3:
        ok=True
        break

if ok:
    print("Yes")
else:
    print("No")
n = int(input())
lst = [ [ int(i) for i in input().split() ] for j in range(n) ]
r = 0
for i in range(n-2):
    if lst[i][0] == lst[i][1]:
        if lst[i+1][0] == lst[i+1][1]:
            if lst[i+2][0] == lst[i+2][1]:
                r = 1
if r == 0:
    print("No")
else:
    print("Yes")
n = int(input())
c = 0
flag = False
for _ in range(n):
    a, b = map(int, input().split())
    if a == b:
        c += 1
        if c >= 3:
            flag = True
    else:
        c = 0
print('Yes' if flag else 'No')
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())
count=0
counts=[]
z=[]
for i in range(n):
	x,y=list(map(int,input().split()))
	z.append([x,y])
z.append([-14,-20])
for i in z:
	if i[0]==i[1]:
		count+=1
	else:
		counts.append(count)
		count=0
if max(counts)>=3:
	print('Yes')
else:
	print('No')
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())
ans = False
count = 0
D1, D2 = 0, 0
for i in range(N):
    D1, D2 = list(map(int, input().split()))
    if D1 == D2:
        count += 1
        if count >= 3:
            ans = True
    else:
        count = 0

if ans == True:
    print("Yes")
else:
    print("No")
n=int(input())
c=0
m=1
for i in [0]*n:
    a,b=map(int,input().split())
    if a==b:
        c+=1
        if c==3:
            m=0
    else:
        c=0
print('YNeos'[m==1::2])
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:
        break
if count >= 3:
    print("Yes")
else:
    print("No")
N = int(input())
sub_yes = 0
max_yes = 0
for i in range(N):
    d1,d2 = map(int,input().split())
    if d1 == d2:
        sub_yes += 1
        if sub_yes > max_yes:
            max_yes = sub_yes
    else:
        if sub_yes > max_yes:
            max_yes = sub_yes
        sub_yes = 0
if max_yes >= 3:
    print("Yes")
else:
    print("No")
n = int(input())
s = 0
b = False
for _ in range(n):
    w = input().split()
    if w[0] == w[1]:
        s += 1
        if s == 3:
            b = True
            break
    else:
        s = 0
print('Yes' if b else 'No')
N = int(input())

isDouble = []

for i in range(N):
    temp = [int(j) for j in input().split(" ")]
    if temp[0] == temp[1]:
        isDouble.append(1)
    else:
        isDouble.append(0)

cnt = 0
flg = False

for i in range(len(isDouble)):
    if isDouble[i] == 0:
        cnt = 0
    else:
        cnt += isDouble[i]
    if cnt == 3:
        flg = True
        break

if flg:
    print("Yes")
else:
    print("No")
#!/usr/bin/python3
# -*- coding: utf-8 -*-
n = int(input())
check_list = []
for i in range(n):
    d1, d2 = map(int, input().split())
    if d1 == d2:
        check_list.append(1)
    else:
        check_list.append(0)
flag = 0
for i in range(n - 2):
    if sum(check_list[i:(i+3)]) == 3:
        flag = 1
        break
if flag:
    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)]
a=0
for i in range(n):
  if x[i]==y[i]:
    a+=1
    if a==3:
      break
  else:
    a=0
    
if a>=3:
  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
    else:
        count = 0
if count < 3:
    print("No")
n=int(input())
x,y=[],[]
for i in range(n):
    x_,y_=map(int,input().split())
    x.append(x_)
    y.append(y_)
for i in range(n-2):
    if x[i]==y[i] and x[i+1]==y[i+1] and x[i+2]==y[i+2]:
        print("Yes")
        break
else:
    print("No")
N = int(input())
flug = False
cnt = 0
for _ in range(N):
    D1, D2 = list(map(int, input().split())) 
    if D1 == D2:
        cnt += 1
    else:
        cnt = 0
    if cnt >= 3:
        flug = True
if flug:
    print("Yes")
else:
    print("No")
n=int(input())
cnt=0
ans="No"
for i in range(n):
  d,k=map(int,input().split())
  if d==k:
    cnt+=1
  else:
    cnt=0
  if cnt==3:
    ans="Yes"
    break
print(ans)
import sys

n = int(input())

n_concecutive = 0

for _ in range(n):
    d1, d2 = map(lambda x: int(x), input().split())
    if d1 == d2:
        n_concecutive += 1
        if n_concecutive >= 3:
            print('Yes')
            sys.exit()
    else:
        n_concecutive = 0
print('No')
N=int(input())
D1,D2=[],[]
for i in range(N):
    d1,d2=map(int,input().split())
    D1.append(d1)
    D2.append(d2)

flag=False
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]:
        flag=True
        break

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

cnt = 0
ans = 0
for d1, d2 in d:
    if d1 == d2:
        cnt += 1
        if cnt >= 3:
            print('Yes')
            exit()
    else:
        cnt = 0

print('No')
N = int(input())
D = [input().split() for i 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'

print(ans)
import sys

input = sys.stdin.readline


def main():
    N = int(input())
    ans = False
    p = 0
    for i in range(N):
        D = list(map(int, input().split()))
        if D[0] == D[1]:
            p += 1
        else:
            p = 0
        if p == 3:
            ans = True
            break
    if ans:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()
N=int(input())
cnt = 0
ans = 0
for i in range(N):
    D1,D2 = map(int,input().split())
    if D1 == D2:
        cnt += 1
        if cnt == 3:
            ans += 1
            print("Yes")
            break
    else:
        cnt = 0
if ans == 0:
    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())

count_max = 0
count = 0
for i in range(n):
    d1, d2 = map(int, input().split())
    if d1 == d2:
        count += 1
        count_max = max(count_max, count)
    else:
        count = 0
print("Yes" if count_max >= 3 else "No")
n = int(input())
num = 0
flag = True
for _ in range(n):
    a,b = map(int,input().split())
    if a ==b:num +=1
    else: num =0
    if num ==3:
        flag= False
        print('Yes')
        break
if(flag):print('No')
n = int(input())
c = 0
for i in range(n):
    x,y=map(int,input().split())
    if x==y:
        c+=1
    else:
        c=0
    if c==3:
        print('Yes')
        break
else:
    print("No")
import sys

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

for i in range(N):
    if D[i][0] == D[i][1]:
        count += 1
        if count == 3:
            print('Yes')
            sys.exit()
    else:
        count = 0

print('No')
def main():
    n = int(input())
    count = 0
    res = False
    for _ in range(n):
        d1, d2 = map(int, input().split())
        if d1 == d2:
            count += 1
            if count >= 3:
                res = True
        else:
            count = 0
    if res:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()
N = int(input())
D = [tuple(map(int, input().split())) for _ in range(N)]
cnt = 0
for d1, d2 in D:
    if d1 == d2:
        cnt += 1
    else:
        cnt = 0
    if cnt == 3:
        print('Yes')
        exit()
print('No')
n = int(input())

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

    if count == 3:
        ans = True
        break

print('Yes') if ans else print('No')
#from collections import deque,defaultdict
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7
#R = 998244353

def ddprint(x):
  if DBG:
    print(x)

n = inn()
x = 0
for i in range(n):
    d,e = inm()
    if d==e:
        x += 1
        if x==3:
            print('Yes')
            exit()
    else:
        x = 0
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')
import sys
n=int(input())
ans=0
for i in range(n):
    d1,d2=map(int,input().split())
    if ans==3:
        continue
    if d1==d2:
        ans+=1
    else:
        ans=0
if ans==3:
    print("Yes")
else:
    print("No")
n = int(input())
ans = 0
f1, f2, f3 = 0, 0, 0
for i in range(n):
    f3 = f2
    f2 = f1
    d1, d2 = map(int, input().split())
    f1 = d1 == d2
    if f1 == f2 == f3 == 1:
        ans = 1
print('Yes' if ans else 'No')
def main():
  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")
      return

  print("No")

main()
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
#======================================================#
def main():
    n = II()
    dd = [MII() for i in range(n)]
    cnt = 0
    for d1, d2 in dd:
        if d1 != d2:
            cnt = 0
        else:
            cnt += 1
        if cnt == 3:
            print('Yes')
            return
    print('No')

if __name__ == '__main__':
    main()
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def main():
    n = I()
    ans = 0
    temp = 0
    for _ in range(n):
        d1, d2 = MI()
        if d1 == d2:
            temp += 1
        else:
            temp = 0
        ans = max(ans, temp)
    if ans >= 3:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()
def resolve():
    import sys
    input = sys.stdin.readline

    n = int(input().rstrip())
    count = 0
    for i in range(n):
        d1, d2 = [int(x) for x in input().rstrip().split(" ")]
        if d1 == d2:
            count += 1
            if count >= 3:
                print("Yes")
                return
        else:
            count = 0

    print("No")


if __name__ == "__main__":
    resolve()
N = int(input())
counter =0
for i in range(N):
    D = list(map(int, input().split(' ')))
    if (D[0]==D[1]):
        counter = counter+1
    else:
        counter = 0
    if (counter==3):
        print('Yes')
        exit(0)
print('No')
#
# 179B
#
n = input()
n = int(n)
s = ''
for i in range(n):
    t = input()
    t = t.replace(' ','')
    t = list(t)
    if t[0]==t[1]:
        s = s+'1'
    else:
        s = s+'0'

if '111' in s:
    print('Yes')
else:
    print('No')
n = int(input())
t = 0
f = False
for i in range(n):
    a,b = map(int, input().split())
    if a == b:
        t += 1
    else:
        t = 0
    if t>= 3:
        f = True
        # break

if f:
    print("Yes")
else:
    print("No")
N = int(input())
x = [0] * N
y = [0] * N
for i in range(N):
    x[i], y[i] = map(int, input().split())

ansl=[]
ans=0
for i in range(N):
    if x[i]==y[i]:
        ans+=1
    else:
        ansl.append(ans)
        ans=0
ansl.append(ans)
if max(ansl)>=3:
    print('Yes')
else:
    print('No')
N = int(input())
D = [tuple(map(int, input().split())) for _ in range(N)]
c = 0
for a, b in D:
    if a == b: c += 1
    else: c = 0
    if c >= 3:
        print('Yes')
        exit()
print('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")
    break

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

exist = False
for i in range(n-2):
    for j in range(3):
        if d[i+j][0] != d[i+j][1]:
            break
    else:
        exist = True
if exist:
    print('Yes')
else:
    print('No')
n=int(input())
score=[]
point=0
for i in range(n):
  d=input().split()
  if d[0]==d[1]:
    point+=1
    score.append(point)
  else:
    point=0
    score.append(point)

if max(score)>=3:
  print("Yes")
else:
  print("No")
N=int(input())
flag = 0
for i in range(N):
  d1,d2 = map(int,input().split())
  if d1==d2:
    if flag<2:
      flag+=1
    else:
      print("Yes")
      exit()
  else:
    flag = 0
print("No")
N = int(input())
c1 = 0
c2 = 0
for i in range(N):
    d1,d2 = map(int,input().split())
    if d1 == d2:
        c1 += 1
    else:
        c1 = 0
    if c1 == 3:
        c2 += 1
if c2 > 0:
    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')
      exit()
  else:
    count = 0
print('No')
n = int(input())
s = "aaa"
for i in range(n):
  d1 , d2 = map(int,input().split(" "))
  if d1 == d2:
    s += "b"
  else:
    s += "c"

if "bbb" in s:
  print("Yes")
else:
  print("No")
N = int(input())


isSucceed = False
cnt = 0
f = False
for _ in range(N):
    d1, d2 = map(int,input().split())
    if d1 == d2:
        if not isSucceed:
            isSucceed = True
            cnt = 1
        else:
            cnt += 1
            if cnt >= 3:
                f = True
                
    else:
        isSucceed = False
        cnt = 0

if f:
    print("Yes")
else:
    print("No")
x=int(input())
List=[]
counter=0
for i in range(x):
  List.append(list(map(int,input().split())))
for i in range(len(List)):
  if List[i][0]==List[i][1]:
    counter+=1
  else:
    counter=0
  if counter ==3:
    print("Yes")
    break
if counter<3:
  print("No")
N=int(input())
d=[0]*N;D=[0]*N
s=0
for i in range(N):
  d[i],D[i]=map(int,input().split())
  if d[i]==D[i]:s+=1
  else:s=0
  if s==3:
    print('Yes')
    exit()
    
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())
flag = 0
flagg = 1
for _ in range(n):
    a, b = map(int, input().split())
    if flagg:
        if a==b:
            flag+=1
        else:
            flag = 0
        if flag==3:
            print('Yes')
            flagg = 0
if flag<3:
    print('No')
import sys
input = sys.stdin.readline
def main():
    N = int(input())
    D = [list(map(int, input().split())) for i in range(N)]
    cnt = 0
    for a, b in D:
        if a == b:
            cnt += 1
        else:
            cnt = 0
        if cnt == 3:
            print('Yes')
            return
    print('No')

if __name__ == '__main__':
    main()
N = int(input())
cnt = 0
f = False
for i in range(N):
    d1, d2 = map(int, input().split())
    if d1 == d2:
        cnt += 1
    else:
        cnt = 0
    if cnt >= 3:
        f = True
if f:
    print('Yes')
else:
    print('No')
def main():
    n = int(input())
    cnt = 0
    for i in range(0, n):
        d_1, d_2 = map(int, input().split())
        if d_1 == d_2:
            cnt += 1
        else :
            if cnt < 3 :
                cnt = 0

    if cnt >= 3:
        print("Yes")
    else :
        print("No")
main()
N = int(input())
x = [0] * N
y = [0] * N
for i in range(N):
    x[i], y[i] = map(int, input().split())
          


n = 0
for i in range(N):
    if x[i] == y[i]:
        n = n+1
    elif n >=3:
        break
    elif x[i] != y[i]:
        n = 0

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

cnt = 0
ans = 'No'

for _ in range(N):
    D = input().split()
    cnt = (cnt + 1)*(D[0] == D[1])
    if cnt == 3:
        ans = 'Yes'

print(ans)
def get_pair():
    return map(int, input().split())

cnt = 0
ans = "No"
for idx in range(int(input())):
    D1, D2 = get_pair()
    if D1 == D2:
        cnt += 1
    else:
        cnt = 0

    if cnt >= 3:
        ans = "Yes"
        break
print(ans)
N = int(input())
ans = 'No'
ls = []
for i in range(N):
    d1,d2 = map(int,input().split())
    ls.append([d1,d2])
ii = 0
for i in range(N):
    if ls[i][0] == ls[i][1]:
        ii += 1
    else:
        ii = 0

    if ii == 3:
        ans = 'Yes'
        break
print(ans)