n=int(eval(input()))

alist=[0]*n

for i in range(n):

  a,b=list(map(int, input().split()))

  if a==b:

    if i==0:

      alist[0]=1

    else:

      alist[i]=alist[i-1]+1

if max(alist)>=3:

  print('Yes')

else:

  print('No')
n=int(eval(input()))

alist=[0]*n

for i in range(n):

  a,b=list(map(int, input().split()))

  if a==b:

      alist[i]=alist[max(i-1,0)]+1

if max(alist)>=3:

  print('Yes')

else:

  print('No')

n = int(eval(input()))
alist = [0] * n
for i in range(n):
    a, b = list(map(int, input().split()))
    if a == b:
        if i == 0:
            alist[0] = 1
        else:
            alist[i] = alist[i - 1] + 1
if max(alist) >= 3:
    print("Yes")
else:
    print("No")

n = int(eval(input()))
alist = [0] * n
for i in range(n):
    a, b = list(map(int, input().split()))
    if a == b:
        alist[i] = alist[max(i - 1, 0)] + 1
if max(alist) >= 3:
    print("Yes")
else:
    print("No")

-        if i == 0: -            alist[0] = 1 -        else: -            alist[i] = alist[i - 1] + 1 +        alist[i] = alist[max(i - 1, 0)] + 1