peterverebics/CodeNet_Python_118 huggingface dataset:
n = int(input())
l = [list(map(int, input().split())) for l in range(n)]
tmp = 0
ans = False
for i in range(n):
    if l[i][0] == l[i][1]:
        tmp += 1
        if tmp == 3:
            ans = True
            break
    else:
        tmp = 0
if ans:
    print("Yes")
else:
    print("No")
n = int(input())
ans = 0
cnt = 0
ch = [[0,0]]*1000
for i in range(n):
    a,b = map(int,input().split())
    ch.append([a,b])
    if a == b:
        cnt += 1
    else:
        ans = max(ans,cnt)
        cnt = 0
for i in range(len(ch)):
    if ch[i][0] != ch[i][1]:
        break
else:
    print("Yes")
    exit()
if ans >= 3:
    print("Yes")
else:
    print("No")
N = int(input())

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


print("Yes" if flg else "No")
n=int(input())
count=0
l=[]
for _ in range(n):
    d1,d2=map(int,input().split())
    if d1==d2:
        count+=1
    else:
        count=0
    l.append(count)
if l.count(3)!=0:
    print('Yes')
else:
    print('No')
N = int(input())
A=[list(map(int, input().split())) for i in range(N)]
num = 0
zoro = 0
while num < N:
  if A[num][0] ==A[num][1]:
    num +=1
    zoro +=1 
  else:
    num +=1
    if zoro >2:
      zoro = zoro
    else:
      zoro = 0
if zoro >2 :
  print("Yes")
else:
  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")
      break
  else:
    cnt=0
else:
  print("No")
cnt=0
b=True
for i in range(int(input())):
    x,y=list(map(int,input().split()))
    if x==y:
        cnt+=1
    else:
        cnt=0
    if cnt==3:
        b=False
        print("Yes")
if b:
    print('No')
N = int(input())
D1 = [0] * N
D2 = [0] * N
for i in range(N):
    D1[i], D2[i] = map(int, input().split())
c = 0
a = 0
    
for d1, d2 in zip(D1, D2):
  if d1 == d2:
    c += 1
  else:
    c = 0
  if c >= 3:
    print("Yes")
    break

if c < 3:
  print("No")
n = int(input())
d = [list(map(int,input().split())) for _ in range(n)]
cnt = ""
for x,y in d:
    if x==y:
        cnt+="1"
    else:
        cnt+="0"
        
cnt = cnt.split("0")
ans = 0
for s in cnt:
    ans = max(ans,len(s))
print("Yes" if ans>=3 else "No")
n = int(input())
cnt = 0
f = False
for i in range(n):
    a = list(map(int, input().split()))
    if a[0] == a[1]:
        cnt += 1
    else:
        cnt = 0
    if cnt == 3:
        f = True
if f:
    print("Yes")
else:
    print("No")
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
ips = lambda:input().split()
import collections
import math
import itertools
import heapq as hq
n = ni()
cnt=0
f=False
for i in range(n):
    d1,d2 = ma()
    if d1==d2:
        cnt+=1
    else:
        cnt=0
    if cnt==3:
        f=True
        break
yn(f)
n = int(input())
z = []
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())
ds = []
for i in range(n):
  d_1, d_2 = map(int, input().split())
  ds.append((d_1, d_2))
for j in range(n-2):
  if ds[j][0] == ds[j][1] and ds[j+1][0] == ds[j+1][1] and ds[j+2][0] == ds[j+2][1]:
    print("Yes")
    exit()
print("No")
N = int(input())
X = []
Y = []
answer = 'No'
for i in range(N):
    x,y = map(int, input().split())
    X.append(x)
    Y.append(y)
for j in range(N-2):
    if ((X[j]==Y[j])and(X[j+1]==Y[j+1])and(X[j+2]==Y[j+2])):
        answer = 'Yes'
print(answer)
def main():
    n = int(input())
    D = [list(map(int, input().split())) for i in range(n)]
    for i in range(2, n):
        if D[i-2][0] == D[i-2][1]:
            if D[i-1][0] == D[i-1][1]:
                if D[i][0] == D[i][1]:
                    print('Yes')
                    exit()
    print('No')
if __name__ == '__main__':
    main()
n = int(input())
d = []
c = 0
ans = 'No'
for i in range(n):
    d1, d2 = [int(_) for _ in input().split()]
    if d1 == d2:
        c += 1
    else:
        c = 0
    if c == 3:
        ans = 'Yes'
print(ans)
n = int(input())
d = [list(map(int, input().split())) for _ in range(n)]
x = 0

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

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

count = [0]
for p in P:
    if p[0] == p[1]:
        count.append(count[-1]+1)
    else:
        count.append(0)

if max(count) >= 3:
    print("Yes")
else:
    print("No")
N = int(input())
A = []
B = []
s = 0
for x in range(N):
  a, b = input().split()
  a = int(a)
  b = int(b)
  A.append(a)
  B.append(b)
for i in range(N):
  if A[i] == B[i]:
    s = s+1
  else:
    if s >= 3:
      s = s + 0
    else:
      s = 0
if s >= 3:
  print('Yes')
else:
  print('No')
N = int(input())
D = [list(map(int,input().split())) for _ in range(N)]

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

print("Yes" if flag == 1 else "No")
n=int(input())
c=0
m=0
for i in range(n):
  a,b=map(int,input().split())
  if a==b:
    c+=1
  else:
    c=0
  m=max(c,m)
if m>=3:
  print("Yes")
else:
  print("No")
#print(c)
import sys
input=sys.stdin.readline

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)

count=0
for i in range(n):
    if l[i]==1:
        count+=1
    else:
        count=0
    if count==3:
        print('Yes')
        sys.exit()
print('No')
if __name__=="__main__":
    N = int(input())
    same = 0
    for i in range(N):
        D1, D2 = (int(x) for x in input().split())
        if D1==D2:
            same += 1
        else:
            if same>=3:
                continue
            else:
                same = 0
    if same>=3:
        print('Yes')
    else:
        print('No')
n = int(input())
count = 0
for i in range(n):
    d1, d2 = input().split()
    if d1 == d2:
        count += 1
    else:
        count = 0
    if count == 3:
        print("Yes")
        exit()
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())
l=[list(map(int,input().split())) for _ in range(n)]
f=[]
for x in l:
	f.append(x[0]==x[1])
l=f.copy()
i=0
while i<n:
	j=1
	while i+j<n and l[i+j]==l[i] and l[i]:
		j+=1 
	if j>2:
		print('Yes')
		break	
	i+=j
else:
	print('No')
n = int(input())
ans = 'No'
cnt = 0
for _ in range(n):
    a, b = map(int, input().split())
    if a == b:
        cnt += 1
        if cnt >= 3:
            ans = 'Yes'
        continue
    cnt = 0
print(ans)
N = int(input())
S = []
judge = 0
for i in range(N):
    S += [input().split()]
for i in range(N):
    if i <= N-3:
        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())
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())
cnt = 0
ans = False
for i in range(n):
    a, b = map(int,input().split())
    if a==b:
        if cnt == 2:
            ans = True
            break
        cnt += 1
    else:
        cnt = 0
    
    
if ans:
    print('Yes')
else:
    print('No')
n=int(input())
ans="No"
num=0
for i in range(n):
    d1,d2=list(map(int,input().split()))
    if d1==d2:
        num+=1
        if num==3:
            ans='Yes'
            break
    else:
        num=0
        continue
print(ans)
N = int(input())
flag = 0
ans = False
for _ in range(N):
    d1,d2 = map(int,input().split())
    if d1==d2:
        flag += 1
        if flag==3:
            ans = True
            break
    else:
        flag = 0
print('Yes' if ans else 'No')
n = int(input())
cnt = 0
p = 0
for i in range(n):
    a,b = map(int,input().split())
    if(a == b):
        cnt += 1
    else:
        cnt *= 0
    if(cnt >= 3):
        p = 1
if(p == 1):
    print('Yes')
else:
    print('No')
roop_num = int(input())

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

z_counter = 0
flg = False

for i in range(roop_num):
  if(x[i] == y[i]):
    z_counter = z_counter +1
  else:
    z_counter = 0
  if(z_counter == 3):
    flg = True
    break

if(flg):
  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-3):
        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())
xy = [map(int, input().split()) for _ in range(N)]
x, y = [list(i) for i in zip(*xy)]
count = 0
for i in range(N-3):
    if x[i] == y[i] and x[i+1] == y[i+1] and x[i+2] == y[i+2]:
        count += 1
        print("Yes")
        break

if count == 0:
    print("No")
import numpy as np
n = int(input())
d = np.array([list(map(int,input().split())) for i in range(n)])
D = np.abs(d[:,0]-d[:,1])
f = False
for i in range(n-3):
    if D[i:i+3].sum() == 0:
        f = True
        break
print('Yes' if f else 'No')
N = int(input())
cnt = []
for i in range(N):
    a,b= map(int, input().split())
    if a == b:
        cnt.append(1)
    else:
        cnt.append(0)

from itertools import groupby
gr = groupby(cnt)
for key, group in gr:
    if len(list(group)) >= 3:
        print('Yes')
        exit()
print('No')
N=int(input())
j=0
for i in range(N):
  D1,D2=map(int,input().split())
  if D1==D2:
    j+=1
  else:
    j=0
if j>=3:
  print('Yes')
else:
  print('No')
n = int(input())
d1 = [0]*n
d2 = [0]*n
h = 'No'
for i in range(n):
    d1[i], d2[i] = map(int, input().split())
    if i > 2:
        if d1[i] == d2[i]:
            if d1[i-1] == d2[i-1]:
                if d1[i-2] == d2[i-2]:
                    h = 'Yes'
                    break
print(h)
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
	ans = max(ans, tmp)
print("Yes" if ans >= 3 else "No")
n = int(input())
x = [list(map(int,input().split())) for i in range(n)]

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

  cnt = 0
  for i in range(N):
    if cnt >= 3:
      return 'Yes'
    if x[i] == y[i]:
      cnt += 1
    else:
      cnt = 0
  return 'No'

print (solution())
N=input()
n=int(N)
x=0
for s in range(n):
  ds1,ds2=input().split()
  Ds1=int(ds1)
  Ds2=int(ds2)
  if Ds1==Ds2:
    x+=1
  else:
    x+=0
if x>3:
  print("Yes")
else:
  print("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
        if count >= 3:
            answer = 'Yes'

    print(answer)


if __name__ == '__main__':
    main()
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())
c=[]
for i in range(n):
  a,b=map(int,input().split())
  if a==b:
    c.append(1)
  else:
    c.append(0)
cnt=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:
      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 > 1 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 and n != i+1 :
  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:
            pass
    if a!=b:
        count==0
import sys
n = int(input())
x = 0
for i in range(n):
    d1, d2 = map(int, input().split())
    if d1 != d2:
        x = 0
    else:
        x += 1
        if x == 3:
            print("Yes")
            sys.exit
if x != 3:
    print("No")
cnt = 0
n = int(input())
for i in range(0,n):
    d1, d2 = map(int, input().split())
    if d1 == d2:
        cnt += 1
        if cnt == 3 :
            print("Yes")
            break
    else:
        cnt == 0
        
    if cnt != 3 and i == n-1:
        print("No")
n=int(input())
ans=0
x=0
for i in range(n):
    a,b=map(int,input().split())
    if a==b and i==x+1:
        ans+=1
        x=i
        if ans==3:
            x=0
            break
    elif a==b and i!=x+1:
        x=i
        ans=0
if ans==3:
    print('Yes')
else:
    print('No')
N = int(input().strip())
 
 
 
a = []
c = []
f = 0
s="No"
for i in range(N):
    array = list(map(int, input().strip().split()))
    a.append(array)
 
    
for i in range(N):
	if(f == 0 or f == i-1):
		if(a[i][0] == a[i][1]):
			f+=1
		else:
			if(f >=3):
				s="Yes"
			f=0
if(f >=3):
	s="Yes" 
 
if(s=="Yes"):
  print("Yes")
else:
  print("No")
ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(map(int, input().split()))

n = ii()
b = []
c = [0]
for i in range(n):
    l = li()
    b.append(1 if l[0] == l[1] else 0)
    if i != 0:
        c.append(c[i-1]+1 if b[i] == 1 else 0)

print("Yes" if max(c) > 2 else "No")
n = int(input())
x = 0

for i in range(n):
    a, b = map(int, input().split())
    if a == b:
        x += 1
        
if x >= 3:
    print('Yes')
else:
    print('No')
n = int(input())
d = [list(map(int, input().split())) for _ in range(n)]

for i in range(n - 2):
  if all([d[i + j][0] == d[i + j][1] for j in range(2)]):
    print('Yes')
    exit()

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

cnt = 0

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

    if cnt >= 3:
        print('Yes')
        exit()
    if a == b:
        cnt += 1

    else:
        cnt = 0

print('No')
import sys

N = int(input())
ans = 0
 
for i in range(N):
  if ans >= 3:
    print("Yes")
    sys.exit()
    
  a,b = map(int,input().split())
  if a == b:
    ans +=1
  else:
    ans =0
print("No")
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]:
        ans = 'Yes'
        break

print(ans)
n = int(input())
ans = "No"
j = 0
for i in range(n):
  d,dd = map(str,input().split())
  if(d==dd):
    if(j>0):
      j += 1
    if(j==3):
      ans = "Yes"
  else:
    j=0
print(ans)
n = int(input())
D = [] * n

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

ans = 0
count = 0

for i in range(1, n):
    if D[i][0] == D[i][1]:
        count += 1
    else:
        ans = max(count, ans)
        count = 0

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

mulArr = []
for _ in range(N):
  arr = list(map(int, input().split(" ")))
  mulArr.append(arr)
print(mulArr)

result = 0
for i in range(0, len(mulArr) - 2):
  print(i)
  if mulArr[i][0] == mulArr[i][1] and mulArr[i + 1][0] == mulArr[i + 1][1] and mulArr[i + 2][0] == mulArr[i + 2][1]:
    result += 1

print(result)
if result != 0:
  print("Yes")
else:
  print("No")
cnt = int(input())
chain = 0
first = 0
second = 0

for i in range(cnt):
    nList = list(map(int, input().split()))
    first = nList.pop()
    second = nList.pop()
    if first == second:
        chain = chain + 1
    else:
        chain = 0

if chain >= 3:
    print("Yes")
else:
    print("No")
import numpy as np

n = int(input(""))
a = np.zeros((n,2))
cnt = 0

for i in range(n): 
    a[i] = input().split()
    if a[i,0] == a[i,1]:
        a[i] = [0]

for i in range(n-1):
    if a[i,0] == a[i+1,0]:
        cnt += 1
        print(cnt , i)
    elif cnt >= 2:
        cnt = cnt
    else:
        cnt = 0


if cnt >= 2:
    print("Yes")
else:
    print("No")
a = []
for i in range(int(input())):
    a.append(input().split())
triplets = 0
for i in a:
    if(i[0] == i[1]):
        triplets += 1
    else:
        triplets = 0

print('Yes' if triplets >= 3 else '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')
  elif a == b:
    count += 1
  else:
    count = 0
print('NO')
n = int(input())
d = [tuple(map(int, input().split())) for _ in range(n)]

ans=0
for k in d:
    if ans >= 3:
        print("Yes")
        raise SystemExit(0)
    if k[0] == k[1]:
        ans+=1
    else:
        ans = 0
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')
  elif a == b:
    count += 1
  else:
    count = 0
print('No')
n=int(input())
k=0
c=0
for i in range(n):
  a,b=map(int,input().split())
  if(a==b):
      k+=1
      if(k>=3):
          c=1
  else:
      k=0

if(c==1):
  print("YES")
else:
  print("NO")
N = int(input())


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

print('Yes' if (ans > 2) else "No")
import itertools
n = int(input())
count = 0
line = [input().split() for i in range(n)]
line = list(itertools.chain.from_iterable(line))

for j in range(len(line)-2):
    if line[j] == line[j+1]:
        if line[j+2] == line[j]:
            count += 1
            print('Yes')
    else:
        continue
if count == 0:
    print('No')
n = int(input())
i = 0
for _ in range(n):
    x, y = map(int, input().split())
    if x == y:
        i += 1
if(i < 3):
    print("No")
else:
    print("Yes")
n=int(input())
g=0
for i in range(n):
  a,b=map(int,input().split(" "))
  if a==b:
    g=g+1
    if g==3:
      break
      break
  else:
    g=0
print(g)
if g==3:
  print("Yes")
else:
  print("No")
N = int(input())

flag = 0

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

if flag >= 3:
    print("Yes")
else:
    print("No")
print("YNEOS"["000" not in "".join([str(eval(input().replace(" ","-")))for _ in "_"*int(input())])::2])
n = int(input())
flag= True
count = 0
for i in range(n):
  a,b = list(map(int, input().split()))
  if a==b:
    count += 1
  else:
    count= 0
  if count==3:
    flag = True
if flag:
  print("Yes")
else:
  print("No")
import sys

n = int(input())
cnt = 0
for i in range(n):
    a,b = map(int,input().split())
    if cnt == 3:
        print('Yes')
        sys.exit()
    if a == b:
        cnt += 1
    else:
        cnt = 0
print('No')
import sys
si=sys.stdin.readline

n=int(si())
t=0
while n:
  n-=1
  a,b=[int(e) for e in si().split()]
  if a==b:
    t+=1
  else:
    t=0
if t>=3:
  print('Yes')
else:
  print('No')
n=int(input())
from itertools import groupby as gb
l=[eval(input().replace(' ','==')) for i in range(n)]

var=[(a,len(list(b))) for a,b in gb(l)]
for a,b in var:
    if b>=3:print("Yes");exit()
print("No")
n = int(input())
count = 0
for i in range(n):
  d1, d2 = map(int, input().split())
  if count > 2:
    break
  elif d1 == d2:
    count += 1
  else:
    count == 0
if count > 2:
  print("Yes")
else:
  print("No")
n = int(input())

pv = []
con = 0

while n > 0:
    n -= 1
    s = str(input())
    d = s.split()
    if d[0] == d[1]:
        con += 1
    else:
        pv += [con]
        con = 0

pv += [con]
ans = max(pv)

if ans >= 3:
    print('Yes')
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'

print(result)
a =int( input())
_number=0;_kaerichi="No"
for i in range(a):
    b, c = map(int, input().split())
    if(b==c):
        _number+=1
    if(_number==3):
        _kaerichi="Yes"
print(_kaerichi)
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-1):
    if x[i] == y[i]:
        n = n+1
    elif n >=3:
        break
    else:
        n = 0

if n >= 3:
    print("Yes")
else:
    print("No")
N = int(input(""))
count = 0
for i in range(N):
    D = (input(""))
    l = D.split()
    l_i = [int(s) for s in l]
    if l_i[0] == l_i[1]:
        count += 1
if count > 2:
    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')

main()
n = int(input())
count = 0
flag = False
c = [0]*n
while count < n:
  a, b = map(int, input().split())
  count += 1
  if a == b and count < n:
    a, b = map(int, input().split())
    count += 1
    if a == b and count < n:
      a, b = map(int, input().split())
      count += 1
      if a == b and count < n:
        flag = True
        print("Yes")
        break

if flag == False:
  print("No")
N = int(input())
D = [list(map(int, input().split())) for i in range(N)]
if 3 < N:
    for i in range(N-3):
        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()
else:
    print('No')
    exit()
print('No')
n=int(input())
k=0
for i in range(n):
  a,b=map(int,input().split())
  if(a==b):
    k+=1
if(k>=3):
  print("YES")
else:
  print("NO")
def solution():
  N = int(input())
  xy = [map(int, input().split()) for _ in range(N)]
  x, y = [list(i) for i in zip(*xy)]

  cnt = 0
  flg = 0
  for i in range(N):
    if x[i] == y[i]:
      if flg+1 == i:
        cnt += 1
        flg = i
      else:
        cnt = 0

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

print (solution())
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
if count == 3:
	print('Yes')
else:
	print('No')
n = int(input())
d = [tuple(map(int, input().split())) for _ in range(n)]

ans=0
for k in d:
    if k[0] == k[1]:
        ans+=1
print("YNeos"[ans<3::2])
n = int(input())

c = 0

for _ in range(n):
    d, e = map(int,input().split())
    if d == e:
        c += 1

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

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

li = []
for i in string:
    li.append(int(i[0]) - int(i[1]))

i = 0
c = 0
nli = len(li) - 1

while i != nli:
    if i == 0:
        c += 1
        if c == 3:
            print('Yes')
            exit()
    if i != 0:
        c = 0
    
print('No')
N = int(input())
cnt = []
for i in range(N):
    a, b = map(int, input().split())
    if a == b:
        cnt.append(1)
    else:
        cnt.append(0)

from itertools import groupby
for key, group in groupby(cnt):
    if  len(list(group)) >= 3:
        print('Yes')
        exit()
print('No')
n = int(input())
lst = []
for i in range(n):
	lst.append(list(map(int,input().split())))
print(lst)

cnt = 0

for i in range(n):
	if lst[i][0]==lst[i][1]:
		cnt += 1
	else:
		cnt = 0
	if cnt == 3:
		print('Yes')
		exit()
print('No')