it = lambda: list(map(int, input().strip().split()))





def solve():

    n = int(eval(input()))

    ok = False

    cnt = 0

    for _ in range(n):

        a, b = it()

        if a == b:

            cnt += 1

            if cnt == 3:

                ok = True

        else:

            cnt = 0

    return 'Yes' if ok else 'No'



if __name__ == '__main__':

    print((solve()))
it = lambda: list(map(int, input().strip().split()))





def solve():

    n = int(eval(input()))

    F = [0] * n

    S = [0] * n

    for i in range(n):

        a, b = it()

        F[i] = a

        S[i] = b

    

    cnt = 0

    for i in range(n):

        if F[i] == S[i]:

            cnt += 1

            if cnt == 3:

                return 'Yes'

        else:

            cnt = 0

    return 'No'





if __name__ == '__main__':

    print((solve()))
it = lambda: list(map(int, input().strip().split()))


def solve():
    n = int(eval(input()))
    ok = False
    cnt = 0
    for _ in range(n):
        a, b = it()
        if a == b:
            cnt += 1
            if cnt == 3:
                ok = True
        else:
            cnt = 0
    return "Yes" if ok else "No"


if __name__ == "__main__":
    print((solve()))

it = lambda: list(map(int, input().strip().split()))


def solve():
    n = int(eval(input()))
    F = [0] * n
    S = [0] * n
    for i in range(n):
        a, b = it()
        F[i] = a
        S[i] = b
    cnt = 0
    for i in range(n):
        if F[i] == S[i]:
            cnt += 1
            if cnt == 3:
                return "Yes"
        else:
            cnt = 0
    return "No"


if __name__ == "__main__":
    print((solve()))

-    ok = False +    F = [0] * n +    S = [0] * n +    for i in range(n): +        a, b = it() +        F[i] = a +        S[i] = b -    for _ in range(n): -        a, b = it() -        if a == b: +    for i in range(n): +        if F[i] == S[i]: -                ok = True +                return "Yes" -    return "Yes" if ok else "No" +    return "No"