n = int(eval(input()))

a = []



for _ in range(n):

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

  if aa == b:

    a.append("1")

  else:

    a.append("0")

if "111" in "".join(a):

  print("Yes")

else:

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

count = 0



for _ in range(n):

  d1, d2 = list(map(int, input().split()))

  if d1 == d2:

    count += 1

    if count >= 3:

      print("Yes")

      exit()

  else:

     count = 0

print("No")
n = int(eval(input()))
a = []
for _ in range(n):
    aa, b = list(map(int, input().split()))
    if aa == b:
        a.append("1")
    else:
        a.append("0")
if "111" in "".join(a):
    print("Yes")
else:
    print("No")

n = int(eval(input()))
count = 0
for _ in range(n):
    d1, d2 = list(map(int, input().split()))
    if d1 == d2:
        count += 1
        if count >= 3:
            print("Yes")
            exit()
    else:
        count = 0
print("No")

-a = [] +count = 0 -    aa, b = list(map(int, input().split())) -    if aa == b: -        a.append("1") +    d1, d2 = list(map(int, input().split())) +    if d1 == d2: +        count += 1 +        if count >= 3: +            print("Yes") +            exit() -        a.append("0") -if "111" in "".join(a): -    print("Yes") -else: -    print("No") +        count = 0 +print("No")