N = int(eval(input()))

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

for i in range(N - 2):

    if all(d[0] == d[1] for d in D[i: i + 3]):

        print('Yes')

        exit()

else:

    print('No')

def input_array():

	return list(map(int,input().split()))

  

n=int(eval(input()))

D=[input_array() for i in range(n)]



count=0

for d in D:

	if d[0]==d[1]:

		count+=1

	else:

		count=0



	if count==3:

		break

if count==3:

	print("Yes")

else:

	print("No")
N = int(eval(input()))
D = [tuple(map(int, input().split())) for _ in range(N)]
for i in range(N - 2):
    if all(d[0] == d[1] for d in D[i : i + 3]):
        print("Yes")
        exit()
else:
    print("No")

def input_array():
    return list(map(int, input().split()))


n = int(eval(input()))
D = [input_array() for i in range(n)]
count = 0
for d in D:
    if d[0] == d[1]:
        count += 1
    else:
        count = 0
    if count == 3:
        break
if count == 3:
    print("Yes")
else:
    print("No")

-N = int(eval(input())) -D = [tuple(map(int, input().split())) for _ in range(N)] -for i in range(N - 2): -    if all(d[0] == d[1] for d in D[i : i + 3]): -        print("Yes") -        exit() +def input_array(): +    return list(map(int, input().split())) + + +n = int(eval(input())) +D = [input_array() for i in range(n)] +count = 0 +for d in D: +    if d[0] == d[1]: +        count += 1 +    else: +        count = 0 +    if count == 3: +        break +if count == 3: +    print("Yes")