Problem:
 Score : 200 points    Problem Statement Tak performed the following action N times: rolling two dice.
The result of the i -th roll is D_{i,1} and D_{i,2} .  Check if doublets occurred at least three times in a row.
Specifically, check if there exists at lease one i such that D_{i,1}=D_{i,2} , D_{i+1,1}=D_{i+1,2} and D_{i+2,1}=D_{i+2,2} hold.      Constraints  3 \leq N \leq 100  1\leq D_{i,j} \leq 6  All values in input are integers.         Input Input is given from Standard Input in the following format:  N  D_{1,1}  D_{1,2}  \vdots  D_{N,1}  D_{N,2}       Output Print Yes if doublets occurred at least three times in a row. Print No otherwise.        Sample Input 1 5
1 2
6 6
4 4
3 3
3 2      Sample Output 1 Yes  From the second roll to the fourth roll, three doublets occurred in a row.       Sample Input 2 5
1 1
2 2
3 4
5 5
6 6      Sample Output 2 No       Sample Input 3 6
1 1
2 2
3 3
4 4
5 5
6 6      Sample Output 3 Yes

Solution (Python):
def main():
    n = int(input())
    count = 0
    for i in range(n):
        x, y = map(int, input().split())
        if x == y:
            count += 1
        else:
            count = 0

        if count == 3:
            print('Yes')
            return
    print('No')
if __name__ == "__main__":
    main()

Solution (Python):
n=int(input())
d=[[int(i)for i in input().split()]for j in range(n)]
res="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]:
        res="Yes"
        break
print(res)

Solution (Python):
def f(L):
	for i in range(0,len(L)-2):
		if(L[i][0]==L[i][1] and L[i+1][0]==L[i+1][1] and L[i+2][0]==L[i+2][1]):
			return "Yes"
	return "No"

n=int(input())
L=[]
for i in range(0,n):
	x=input().split()
	L.append(x)
print(f(L))

Solution (Python):
def main():
    N = int(input())
    zorome_count = 0
    for i in range(N):
        d1, d2 = map(int, input().split())
        if d1 == d2:
            zorome_count += 1
        else:
            zorome_count = 0
        
        if zorome_count == 3:
            print('Yes')
            return
    print('No')

if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
bit = 0
for _ in range(n):
    a,b = map(int,input().split())
    if a == b:
        bit += 1
        if bit == 3:
            print("Yes")
            exit()
    else:
        bit = 0
else:
    print("No")

Solution (Python):
ans=0
f=0
for _ in range(int(input())):
    x,y=map(int,input().split())
    if x==y:
        ans+=1
    else:
        ans=0
    if ans>=3:
        f=1
        break
if f:
    print("Yes")
else:
    print("No")

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

Solution (Python):
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")
        break
else:
    print("No")

Solution (Python):



import sys


def std_in():
    return sys.stdin.readline().strip()


def get_ints():
    return map(int, sys.stdin.readline().strip().split())


def main():
    n = int(std_in())

    flag = 0
    for ni in range(n):
        d1, d2 = get_ints()
        if d1 == d2:
            flag += 1
        else:
            flag = 0
        if flag >= 3:
            print("Yes")
            break
    else:
        print("No")


if __name__ == "__main__":
    main()

Solution (Python):
def main():
    n = int(input())
    d = [list(map(int, input().split())) for _ in range(n)]

    for i in range(n - 2):
        if d[i][0] == d[i][1] and d[i + 1][0] == d[i + 1][1] and d[i + 2][0] == d[i + 2][1]:
            print("Yes")
            break
    else:
        print("No")


if __name__ == "__main__":
    main()

Solution (Python):
n=int(input())
d=[list(map(int,input().split())) for i in range(n)]

flg = False
count = 0
for i in range(n):
  if d[i][0] == d[i][1]:
    flg = True
  else:
    flg = False
    count = 0
    
  if flg:
    count += 1
  if count >= 3:
    print('Yes')
    exit(0)
print('No')

Solution (Python):
N = int(input())

check = 0
ans = 0
for n in range(N):
    D1,D2 = map(int,input().split())
    if D1 == D2:
        check += 1
        ans = max(ans,check)
    else:
        check = 0
        ans = max(ans,check)
print('Yes' if ans >= 3 else 'No')

Solution (Python):
n = int(input())
count = 0
ans = 'No'
for _ in range(n):
  a, b = map(int, input().split())
  if a == b:
    count = count + 1
  else:
    count = 0
  if count == 3:
    ans = 'Yes'
print(ans)

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

tmp = 0
for x,y in D:
    if x == y:
        tmp += 1
        if tmp == 3:
            print('Yes')
            break
    else:
        tmp = 0
else:
    print('No')

Solution (Python):
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")

Solution (Python):
n = int(input())
D = [list(map(int, input().split())) for _ in range(n)]

count = 0
ans = 'No'
for dd in D:
    d1, d2 = dd
    if d1 == d2:
        count += 1
    else:
        count = 0
    if count == 3:
        ans = 'Yes'

print(ans)

Solution (Python):
N = int(input())
D = []
for _ in range(N):
    D.append(list(map(int, input().split())))

count = 0

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

print('No')

Solution (Python):
n=int(input())
t=0
d=[list(map(int,input().split())) for i in range(n)]
for i in range(n-2):
    if d[i][0]==d[i][1] and d[i+1][0]==d[i+1][1] and d[i+2][0]==d[i+2][1]:
        t+=1
        break
if t==1:
    print("Yes")
else:
    print("No")

Solution (Python):
import sys
sys.setrecursionlimit(10**6)


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


if __name__ == '__main__':
    main(sys.stdin.readline, print)

Solution (Python):

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

Solution (Python):
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')

Solution (Python):
cnt = 0
n = int(input())
for i in range(n):
    n,m = map(int,input().split())
    if n == m:
        cnt += 1
    else:
        cnt = 0
    if cnt == 3:
        print("Yes")
        exit()
print("No")

Solution (Python):
N = int(input())
a = 0
valid = False
for i in range(N):
    d1, d2 = map(int,input().split())
    if d1 == d2:
        a += 1
        if a == 3:
            valid = True
    else:
        a = 0
if valid:
    print("Yes")
else:
    print("No")

Solution (Python):
N = int(input())
ans = []
for i in range(N):
    D1,D2 = map(int,input().split())
    if D1 == D2:
        ans.append('1')
    else:
        ans.append('0')
S = ''.join(ans)
if '111' in S:
    print('Yes')
else:
    print('No')

Solution (Python):
N = int(input())
Sum = 0
flag = False
for i in range(N):
    a, b = map(int, input().split())
    if a == b:
        Sum += 1
    else:
        Sum = 0
    if Sum == 3:
        flag = True

if flag:
    print("Yes")

else:
    print("No")

Solution (Python):
N = int(input())
c = 0
ans = "No"
for i in range(N):
  a,b = map(int,input().split())
  if a == b:
    c += 1
  else:
    c = 0
  if c == 3:
    ans = "Yes"
print(ans)

Solution (Python):
N = int(input())
D = []
for i in range(N):
    a,b = map(int,input().split())
    D.append([a,b])
for i in range(N-2):
    if D[i][0] == D[i][1]:
        if D[i+1][0] == D[i+1][1]:
            if D[i+2][0] == D[i+2][1]:
                print('Yes')
                exit()
print('No')

Solution (Python):
N = int(input())
count = 0
ans = "No"

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

Solution (Python):
N = int(input())
Ds = [list(map(int, input().split())) for _ in range(N)]

count = 0
for D in Ds:
    if D[0] == D[1]:
        count+=1
        if count == 3:
            break
    else:
        count = 0

if count == 3:
    print("Yes")
else:
    print("No")

Solution (Python):
N=int(input())
num=0
for i in range(N):
    x,y=map(int,input().split())
    if x==y:
        num+=1
    else:
        num=0
    if num==3:
        print("Yes")
        exit()
print("No")

Solution (Python):
N=int(input())
D=list()
for i in range(N):
    tmp=list(map(int,input().split()))
    D.append(tmp[0]==tmp[1])
for i in range(N-2):
    if D[i]==D[i+1]==D[i+2]==True:
        print("Yes")
        break
else:
    print("No")

Solution (Python):
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

from collections import deque
from collections import Counter
import bisect
def main():
    N = I()
    cnt = 0
    for i in range(N):
        d_1, d_2 = MI()
        if d_1 == d_2:
            cnt += 1
        else:
            cnt = 0
        if cnt == 3:
            print('Yes')
            exit()
    print('No')
if __name__ == "__main__":
    main()

Solution (Python):
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")

Solution (Python):
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)

Solution (Python):
n=int(input())
l=0
for i in range(n):
    a,b=map(int,input().split())
    if a==b:
        l+=1
    else:
        if l>=3:
            print("Yes")
            exit()
        l=0
print("Yes" if l>=3 else "No")

Solution (Python):
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  a and b>=3:print("Yes");exit()
print("No")

Solution (Python):
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")

Solution (Python):
n=int(input())
cnt=0
for _ in range(n):
    d=input().split()
    if d[0]==d[1]:
        cnt+=1
    else:
         cnt=0
    if cnt==3:
        print("Yes")
        exit()
print("No")

Solution (Python):
import sys

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()
count = 0

for i in range(N):
    d1, d2 = LI()
    if d1 == d2:
        count += 1
    else:
        count = 0
    
    if count == 3:
        print('Yes')
        exit()

print('No')

Solution (Python):
N = int(input())
D = [list(map(int,input().split())) for _ 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] and D[i+2][0]==D[i+2][1]:
        flag = 1
        break
if flag==1:
    print("Yes")
else:
    print("No")

Solution (Python):
N = int(input())
cnt = 0
ans = "No"
for _ in range(N):
    d, a = list(map(int, input().split()))
    if d == a:
        cnt += 1
    else:
        cnt = 0
    if cnt >= 3:
        ans = "Yes"

print(ans)

Solution (Python):
n  = int(input(''))

cnt=0
result="No"
for i in range(n):
    d12 = input('').split()
    d1 = d12[0]
    d2 = d12[1]
    if d1 == d2:
        cnt+=1
        if cnt ==3:
            result = "Yes"
    else:
        cnt=0


print(result)

Solution (Python):
N = int(input())

count = 0
for _ in range(N):
    a, b = list(map(int, input().split(" ")))
    if a == b:
        count += 1
        if count >= 3:
            print("Yes")
            exit()
    else:
        count = 0

print("No")

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

Solution (Python):
n = int(input())
cnt = 0
flag = False
for _ in range(n):
    c, d = map(int, input().split())
    if c == d:
        cnt += 1
    else:
        if cnt >= 3:
            flag = True
        cnt = 0
if cnt >= 3:
    flag = True
print('Yes' if flag else 'No')

Solution (Python):
N = int(input())
x = ''.join(map(str, [len(set(input().split())) for _ in range(N)]))
if '111' in x:
    print('Yes')
else:
    print('No')

Solution (Python):
n = int(input())
d = []
for i in range(n):
    d1,d2 = map(int, input().split())
    d.append([d1,d2])

cnt = 0
for i in range(n-2):
    if d[i][0] == d[i][1] and d[i+1][0] == d[i+1][1] and d[i+2][0] == d[i+2][1]:
        print("Yes")
        exit()
print("No")

Solution (Python):
n=int(input())

lis=[]
for i in range(n):
    d1,d2=map(int,input().split())
    if d1==d2:
        lis.append(1)
    else:
        lis.append(0)

c=0
for i in range(n-2):
    if sum(lis[i:i+3])==3:
        c+=1

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

Solution (Python):
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')

Solution (Python):
n = int(input())

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

res = 0

for i in  range(n):
    a = ab[i][0]
    b = ab[i][1]
    
    if a==b:
        res +=1
    else:
        res =0
    
    if res ==3:
        print("Yes")
        exit()

print("No")

Solution (Python):
n=int(input())
s=[0]
for i in range(n):
    a,b=input().split()
    if a==b :
        s.append(s[-1]+1)
    else:
        s.append(0)

for i in s:
    if i>=3 :
        print('Yes')
        exit()

print('No')

Solution (Python):
n = int(input())
D = [list(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")

Solution (Python):
N = int(input())

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

ans = False
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 = True
        break

if ans:
    print('Yes')
else:
    print('No')

Solution (Python):
n=int(input())
l=[]
for i in range(n):
    lo=input().split()
    lop=[int(i) for i in lo]
    l.append(lop)
poss=0
for i in range(n-2):
    if(l[i][0]==l[i][1] and l[i+1][0]==l[i+1][1] and l[i+2][0]==l[i+2][1]):
        poss=1
        break
if(poss):
    print("Yes")
else:
    print("No")

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

flag = False

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

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

Solution (Python):
import sys
input = sys.stdin.readline


def read():
    N = int(input().strip())
    D = []
    for i in range(N):
        a, b = map(int, input().strip().split())
        D.append((a, b))
    return N, D


def solve(N, D):
    seq = 0
    for a, b in D:
        if a == b:
            seq += 1
        else:
            seq = 0
        if seq >= 3:
            return "Yes"
    return "No"


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))

Solution (Python):
n = int(input())
cnt = 0
for i in range(n):
    r1, r2 = map(int, input().split())
    if r1 == r2:
        cnt += 1
    else:
        cnt = 0
    if cnt == 3:
        print('Yes')
        exit()
print('No')

Solution (Python):
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")

Solution (Python):
n = int(input())
ds = [tuple(map(int,input().split())) for i in range(n)]
ans = 0
x = 0
for i in range(n-1):
    
    if (ds[i][0] == ds[i][1]) and (ds[i+1][0] == ds[i+1][1]):
        x += 1
    else:
        ans = max(ans,x+1)
        x = 0
print("Yes" if max(ans,x+1) >= 3 else "No")

Solution (Python):
N = int(input())
c = 0
f = 0
for i in range(N):
    a,b = [int(a) for a in input().split()]
    if a==b:
        c += 1
    else:
        c = 0
    if c==3: f=1
if f:print("Yes")
else:print("No")

Solution (Python):
N = int(input())

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

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

Solution (Python):
N = int(input())

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

Solution (Python):
n = int(input())
cnt = 0
frag = False
for i in range(n):
    a, b = map(int, input().split())
    if(a == b):
        cnt += 1
    else:
        cnt = 0
    if(cnt == 3):
        frag = True
    if(frag):
        break
if(frag):
    print("Yes")
else:
    print("No")

Solution (Python):
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")

Solution (Python):
import sys
sys.setrecursionlimit(4100000)
import math
import itertools
INF = float('inf')
from heapq import heapify, heappop, heappush
import collections
import bisect

def main():
    n = int(input())
    count = 0
    D1 = []
    D2 = []
    for i in range(n):
        d1, d2 = map(int, input().split())
        D1.append(d1)
        D2.append(d2)
    for i in range(n):
        if D1[i] == D2[i]:
            count += 1
        else:
            count = 0
        if count == 3:
            print('Yes')
            return
    print('No')


if __name__ == '__main__':
    main()

Solution (Python):
from __future__ import division, print_function

import os
import sys
from difflib import SequenceMatcher

 
    
    
from io import BytesIO, IOBase
from collections import Counter,deque
from heapq import heapify,heappush,heappop
from math import gcd,ceil,sqrt,log2,log
from itertools import accumulate,repeat,permutations,compress

from operator import itemgetter
if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip

def rl():
    return list(map(int,input().split()))
def arp(arr):
    return ' '.join([str(i) for i in arr])
    




n, = rl()
ans = 0
while(n):
    n-=1
    a,b = rl()
    if(a==b):
        ans+=1
    else:
        if(ans>=3):
            break
        ans = 0
if(ans>=3):
    print("Yes")
else:
    print("No")





















































































































BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

Solution (Python):
N = int(input())
s = 0
c = 0
for i in range(N):
  x, y = map(int, input().split())
  if x == y:
    s += 1
  else:
    s = 0
  if s >= 3:
    c = 1
if c == 1:
  print("Yes")
else:
  print("No")

Solution (Python):
N = int(input())
l = [0]*N
for i in range(N):
    d1,d2 = map(int,input().split())
    if d1==d2:
        l[i] = 1
ans = 0
for i in range(N-2):
    if l[i]+l[i+1]+l[i+2]==3:
        ans = 1
if ans:
    print("Yes")
else:
    print("No")

Solution (Python):
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
    else:
        cnt = 0
if ans:
    print('Yes')
else:
    print('No')

Solution (Python):
N = int(input())
D = [list(map(int, input().split())) for _ in range(N)]
c, result = 0, 0
for d in D:
  if d[0]==d[1]:
    c += 1
  else:
    c = 0
  if c>=3:
    print("Yes")
    exit()
print("No")

Solution (Python):
N=int(input())
D=[list(map(int,input().split())) for i in range(N)]
m=0
x=0
for d,d2 in D:
    if d==d2:
        x+=1
    else:
        m=max(m,x)
        x=0
m=max(m,x)
print(['No','Yes'][m>=3])

Solution (Python):
N=int(input())
zorome=[]
for i in range(N):
    x,y=map(int,input().split())
    if x==y:
        zorome.append(1)
    else:
        zorome.append(0)

flag=0
for i in range(N-2):
    if zorome[i]==1 and zorome[i+1]==1 and zorome[i+2]==1:
        flag=1
        break
if flag==0:
    print("No")
else:
    print("Yes")

Solution (Python):
"""

"""
count = int(input())

zoro = 0
for _ in range(count):
    d1, d2 = map(int, input().split())
    if d1 == d2:
        zoro += 1
        if zoro == 3:
            print("Yes")
            break
    else:
        zoro = 0
else:
    print("No")

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

for i in range(N - 2):
    if D[i][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")

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

Solution (Python):
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():


    n = I()
    saikoro = []
    for i in range(n):
        a, b = LI()
        saikoro.append((a, b))

    cnt = 0

    for deme in saikoro:
        if len(set(deme)) == 1:
            cnt += 1
        else:
            cnt = 0
        if cnt == 3:
            print("Yes")
            exit(0)

    print("No")

main()

Solution (Python):
def solve():
    N = int(input())
    cnt = 0
    flg = False
    for _ in range(N):
        d1, d2 = map(int,input().split())
        if d1 == d2:
            cnt += 1
        else:
            cnt = 0
        
        if cnt == 3:
            flg = True
    
    if flg:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    solve()

Solution (Python):
n=int(input())
d=[list(map(int,input().split())) for i in range(n)]
for i in range(n-2):
  if d[i][0]==d[i][1]:
    if d[i+1][0]==d[i+1][1]:
      if d[i+2][0]==d[i+2][1]:
        print('Yes')
        exit()
print('No')

Solution (Python):
n=int(input())
c=0
ans=False
for i in range(n):
    a,b=map(int,input().split())
    if a==b:
        c+=1
    else:
        c=0
    if c==3:
        ans=True
if ans:
    print('Yes')
else:
    print('No')

Solution (Python):
N = int(input())

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

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

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

for i in range(2, N):

    if D1[i-2] == D2[i-2] and D1[i-1] == D2[i-1] and D1[i] == D2[i]:
        print("Yes")
        exit()

print("No")

Solution (Python):
n = int(input())
d = [list(map(int, input().split())) for i in range(n)]


ans = [0] * n
for i in range(n):
    if d[i][0] == d[i][1]:
        ans[i] = 1

ans.append(0)
max_cnt = 0
cnt = 0


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

if max_cnt >= 3:
    print("Yes")
else:
    print("No")

Solution (Python):
n = int(input())
a = []
res = False
for i in range(n):
    x, y = map(int, input().split())
    a.append(x == y)
    if i >= 2 and a[-1] and a[-2] and a[-3]:
        res = True
print('Yes' if res else 'No')

Solution (Python):
n = int(input())
d = [list(map(int, input().split())) for i in range(n)]
flag = False
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]:
        flag = True
if flag:
    print("Yes")
else:
    print("No")

Solution (Python):
N = int(input())
cnt = 0
mx = 0
for _ in range(N):
  a,b = map(int,input().split())
  if a==b:
    cnt+=1
    mx = max(cnt,mx) 
  else :
    cnt=0
print("Yes" if mx >2 else "No")

Solution (Python):
N = int(input())

cnt = 0
ans = "No"
for i in range(N):
    d1, d2 = list(map(int, input().split()))
    if d1 == d2:
        cnt += 1
    else:
        cnt = 0
    if cnt == 3:
        ans = "Yes"
        break

print(ans)

Solution (Python):
c=0
for _ in range(int(input())):
  a,b=map(int,input().split())
  if a==b:c+=1
  else:c=0
  if c>2:break
else:print("No");quit()
print("Yes")

Solution (Python):
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7

INF = 10**18
eps = 10**-7

n=int(input())
cnt=0
d=False
for i in range(n):
  x,y=map(int,input().split())
  if x==y:
    cnt+=1
  else:
    cnt=0
  if cnt==3:
    d=True
    break
if d:
  print('Yes')
else:
  print('No')

Solution (Python):
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')
    exit()
print('No')

Solution (Python):
N = int(input())

ans = False
zoro_renzoku = 0

for _ in range(N):
    D_1, D_2 = map(int, input().split())
    if D_1==D_2:
        zoro_renzoku += 1
    else:
        zoro_renzoku = 0
    
    if zoro_renzoku ==3:
        ans = True
        
if ans:
    print("Yes")
else:
    print("No")

Solution (Python):
n = int(input())
same = 0
ans = "No"

for i in range(n):
    d1, d2 = map(int, input().split(" "))
    if d1 == d2:
        same += 1
        if same == 3:
            ans = "Yes"
    else:
        same = 0

print(ans)

Solution (Python):
from sys import stdin


def main():
    _in = [_.rstrip() for _ in stdin.readlines()]
    N = int(_in[0])  
    D_arr = []
    for i in range(N):
        _ = list(map(int, _in[i+1].split(' ')))  
        D_arr.append(_)
    
    ans = 0
    cnt = 0
    for a, b in D_arr:
        if a == b:
            cnt += 1
        else:
            cnt = 0
        if cnt == 3:
            ans = 'Yes'
            break
    else:
        ans = 'No'
    
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
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")

Solution (Python):
N = int(input())

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

print(ans)

Solution (Python):



import sys

N = int(input())

c = 0


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

print("No")

Solution (Python):
'''
Created on 2020/09/19

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  N=int(pin())
  cnt=0
  ans=False
  for i in range(N):
    d,e=map(int,pin().split())
    if d==e:
      cnt+=1
      if cnt==3:
        ans=True
        cnt=0
    else:
      cnt=0
  if ans:
    print("Yes")
  else:
    print("No")
  return 
main()

Solution (Python):
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")

Solution (Python):
N = int(input())
cnt = 0
z = False
for _ in range(N):
    d1, d2 = map(int, input().split())
    if d1 == d2:
        cnt += 1
    else:
        cnt = 0
    if cnt >= 3:
        z = True
if z:
    print("Yes")
else:
    print("No")

Solution (Python):
n = int(input())
dice = [list(map(int,input().split())) for _ in range(n)]
flag = False

a = 0
for i in range(n):
    if dice[i][0] == dice[i][1]:
        a += 1
    else:
        a = 0
    if a >= 3:
        flag = True

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

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

Solution (Python):
def main():
    N = int(input())
    v = 0
    for _ in range(N):
        d1, d2 = input().split()
        if d1 == d2:
            v += 1
        else:
            v = 0
        if v == 3:
            print('Yes')
            exit()
    print('No')


if __name__ == '__main__':
    main()