
import java.util.Scanner;

public class Main {

    public Main() {
    }

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
int N=scan.nextInt();
int u1=0;
        int u2=0;
        int u3=0;

for(int i=0;i<N;i++) {
    int a = scan.nextInt();
    int b = scan.nextInt();
    if (a == b && u1 == 1 && u2 == 1) {
        u3 = 1; }
    else if(a == b && u1 == 1) {u2=1;
    }
else if(a == b){u1=1;}
if(a!=b){u1=0;
u2=0;
}
}
if(u3==1){System.out.println("Yes");}

else{System.out.println("No");}
    }
} import java.util.Scanner; Scanner java.util public class Main {

    public Main() {
    }

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
int N=scan.nextInt();
int u1=0;
        int u2=0;
        int u3=0;

for(int i=0;i<N;i++) {
    int a = scan.nextInt();
    int b = scan.nextInt();
    if (a == b && u1 == 1 && u2 == 1) {
        u3 = 1; }
    else if(a == b && u1 == 1) {u2=1;
    }
else if(a == b){u1=1;}
if(a!=b){u1=0;
u2=0;
}
}
if(u3==1){System.out.println("Yes");}

else{System.out.println("No");}
    }
} Main public Main() {
    } Main {
    } public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
int N=scan.nextInt();
int u1=0;
        int u2=0;
        int u3=0;

for(int i=0;i<N;i++) {
    int a = scan.nextInt();
    int b = scan.nextInt();
    if (a == b && u1 == 1 && u2 == 1) {
        u3 = 1; }
    else if(a == b && u1 == 1) {u2=1;
    }
else if(a == b){u1=1;}
if(a!=b){u1=0;
u2=0;
}
}
if(u3==1){System.out.println("Yes");}

else{System.out.println("No");}
    } main {
        Scanner scan = new Scanner(System.in);
int N=scan.nextInt();
int u1=0;
        int u2=0;
        int u3=0;

for(int i=0;i<N;i++) {
    int a = scan.nextInt();
    int b = scan.nextInt();
    if (a == b && u1 == 1 && u2 == 1) {
        u3 = 1; }
    else if(a == b && u1 == 1) {u2=1;
    }
else if(a == b){u1=1;}
if(a!=b){u1=0;
u2=0;
}
}
if(u3==1){System.out.println("Yes");}

else{System.out.println("No");}
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int N=scan.nextInt(); N scan.nextInt() scan.nextInt scan int u1=0; u1 0 int u2=0; u2 0 int u3=0; u3 0 for(int i=0;i<N;i++) {
    int a = scan.nextInt();
    int b = scan.nextInt();
    if (a == b && u1 == 1 && u2 == 1) {
        u3 = 1; }
    else if(a == b && u1 == 1) {u2=1;
    }
else if(a == b){u1=1;}
if(a!=b){u1=0;
u2=0;
}
} int i=0; int i=0; i 0 i<N i N i++ i++ i {
    int a = scan.nextInt();
    int b = scan.nextInt();
    if (a == b && u1 == 1 && u2 == 1) {
        u3 = 1; }
    else if(a == b && u1 == 1) {u2=1;
    }
else if(a == b){u1=1;}
if(a!=b){u1=0;
u2=0;
}
} {
    int a = scan.nextInt();
    int b = scan.nextInt();
    if (a == b && u1 == 1 && u2 == 1) {
        u3 = 1; }
    else if(a == b && u1 == 1) {u2=1;
    }
else if(a == b){u1=1;}
if(a!=b){u1=0;
u2=0;
}
} int a = scan.nextInt(); a scan.nextInt() scan.nextInt scan int b = scan.nextInt(); b scan.nextInt() scan.nextInt scan if (a == b && u1 == 1 && u2 == 1) {
        u3 = 1; }
    else if(a == b && u1 == 1) {u2=1;
    }
else if(a == b){u1=1;} a == b && u1 == 1 && u2 == 1 a == b && u1 == 1 && u2 == 1 a == b a b u1 == 1 u1 1 u2 == 1 u2 1 {
        u3 = 1; } u3 = 1 u3 1 if(a == b && u1 == 1) {u2=1;
    }
else if(a == b){u1=1;} a == b && u1 == 1 a == b a b u1 == 1 u1 1 {u2=1;
    } u2=1 u2 1 if(a == b){u1=1;} a == b a b {u1=1;} u1=1 u1 1 if(a!=b){u1=0;
u2=0;
} a!=b a b {u1=0;
u2=0;
} u1=0 u1 0 u2=0 u2 0 if(u3==1){System.out.println("Yes");}

else{System.out.println("No");} u3==1 u3 1 {System.out.println("Yes");} System.out.println("Yes") System.out.println System.out System System.out "Yes" {System.out.println("No");} System.out.println("No") System.out.println System.out System System.out "No" String[] args args public class Main {

    public Main() {
    }

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
int N=scan.nextInt();
int u1=0;
        int u2=0;
        int u3=0;

for(int i=0;i<N;i++) {
    int a = scan.nextInt();
    int b = scan.nextInt();
    if (a == b && u1 == 1 && u2 == 1) {
        u3 = 1; }
    else if(a == b && u1 == 1) {u2=1;
    }
else if(a == b){u1=1;}
if(a!=b){u1=0;
u2=0;
}
}
if(u3==1){System.out.println("Yes");}

else{System.out.println("No");}
    }
} public class Main {

    public Main() {
    }

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
int N=scan.nextInt();
int u1=0;
        int u2=0;
        int u3=0;

for(int i=0;i<N;i++) {
    int a = scan.nextInt();
    int b = scan.nextInt();
    if (a == b && u1 == 1 && u2 == 1) {
        u3 = 1; }
    else if(a == b && u1 == 1) {u2=1;
    }
else if(a == b){u1=1;}
if(a!=b){u1=0;
u2=0;
}
}
if(u3==1){System.out.println("Yes");}

else{System.out.println("No");}
    }
} Main

import java.util.Scanner;

public class Main {

    public Main() {
    }

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
int N=scan.nextInt();
int u1=0;
        int u2=0;
        int u3=0;

for(int i=0;i<N;i++) {
    int a = scan.nextInt();
    int b = scan.nextInt();
    if (a == b && u1 == 1 && u2 == 1) {
        u3 = 1; }
    else if(a == b && u1 == 1) {u2=1;
    }
else if(a == b){u1=1;}
if(a!=b){u1=0;
u2=0;
}
}
if(u3==1){System.out.println("Yes");}

else{System.out.println("No");}
    }
}