import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        String line = scan.nextLine();

        int count = 0;
        for (int i = 0; i < Integer.parseInt(line); i++) {
            String dice = scan.nextLine();
            String[] values = dice.split(" ");
            if (count >= 3) {
                System.out.println("Yes");
                return;
            } else {
                if (values[0].equals(values[1])) {
                    count++;
                } else {
                    count = 0;
                }
            }
        }
        
        if (count >= 3) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        String line = scan.nextLine();

        int count = 0;
        for (int i = 0; i < Integer.parseInt(line); i++) {
            String dice = scan.nextLine();
            String[] values = dice.split(" ");
            if (count >= 3) {
                System.out.println("Yes");
                return;
            } else {
                if (values[0].equals(values[1])) {
                    count++;
                } else {
                    count = 0;
                }
            }
        }
        
        if (count >= 3) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
} Main public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        String line = scan.nextLine();

        int count = 0;
        for (int i = 0; i < Integer.parseInt(line); i++) {
            String dice = scan.nextLine();
            String[] values = dice.split(" ");
            if (count >= 3) {
                System.out.println("Yes");
                return;
            } else {
                if (values[0].equals(values[1])) {
                    count++;
                } else {
                    count = 0;
                }
            }
        }
        
        if (count >= 3) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    } main {
        Scanner scan = new Scanner(System.in);
        String line = scan.nextLine();

        int count = 0;
        for (int i = 0; i < Integer.parseInt(line); i++) {
            String dice = scan.nextLine();
            String[] values = dice.split(" ");
            if (count >= 3) {
                System.out.println("Yes");
                return;
            } else {
                if (values[0].equals(values[1])) {
                    count++;
                } else {
                    count = 0;
                }
            }
        }
        
        if (count >= 3) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) String line = scan.nextLine(); line scan.nextLine() scan.nextLine scan int count = 0; count 0 for (int i = 0; i < Integer.parseInt(line); i++) {
            String dice = scan.nextLine();
            String[] values = dice.split(" ");
            if (count >= 3) {
                System.out.println("Yes");
                return;
            } else {
                if (values[0].equals(values[1])) {
                    count++;
                } else {
                    count = 0;
                }
            }
        } int i = 0; int i = 0; i 0 i < Integer.parseInt(line) i Integer.parseInt(line) Integer.parseInt Integer line i++ i++ i {
            String dice = scan.nextLine();
            String[] values = dice.split(" ");
            if (count >= 3) {
                System.out.println("Yes");
                return;
            } else {
                if (values[0].equals(values[1])) {
                    count++;
                } else {
                    count = 0;
                }
            }
        } {
            String dice = scan.nextLine();
            String[] values = dice.split(" ");
            if (count >= 3) {
                System.out.println("Yes");
                return;
            } else {
                if (values[0].equals(values[1])) {
                    count++;
                } else {
                    count = 0;
                }
            }
        } String dice = scan.nextLine(); dice scan.nextLine() scan.nextLine scan String[] values = dice.split(" "); values dice.split(" ") dice.split dice " " if (count >= 3) {
                System.out.println("Yes");
                return;
            } else {
                if (values[0].equals(values[1])) {
                    count++;
                } else {
                    count = 0;
                }
            } count >= 3 count 3 {
                System.out.println("Yes");
                return;
            } System.out.println("Yes") System.out.println System.out System System.out "Yes" return; {
                if (values[0].equals(values[1])) {
                    count++;
                } else {
                    count = 0;
                }
            } if (values[0].equals(values[1])) {
                    count++;
                } else {
                    count = 0;
                } values[0].equals(values[1]) values[0].equals values[0] values 0 values[1] values 1 {
                    count++;
                } count++ count {
                    count = 0;
                } count = 0 count 0 if (count >= 3) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        } count >= 3 count 3 {
            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 static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        String line = scan.nextLine();

        int count = 0;
        for (int i = 0; i < Integer.parseInt(line); i++) {
            String dice = scan.nextLine();
            String[] values = dice.split(" ");
            if (count >= 3) {
                System.out.println("Yes");
                return;
            } else {
                if (values[0].equals(values[1])) {
                    count++;
                } else {
                    count = 0;
                }
            }
        }
        
        if (count >= 3) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        String line = scan.nextLine();

        int count = 0;
        for (int i = 0; i < Integer.parseInt(line); i++) {
            String dice = scan.nextLine();
            String[] values = dice.split(" ");
            if (count >= 3) {
                System.out.println("Yes");
                return;
            } else {
                if (values[0].equals(values[1])) {
                    count++;
                } else {
                    count = 0;
                }
            }
        }
        
        if (count >= 3) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        String line = scan.nextLine();

        int count = 0;
        for (int i = 0; i < Integer.parseInt(line); i++) {
            String dice = scan.nextLine();
            String[] values = dice.split(" ");
            if (count >= 3) {
                System.out.println("Yes");
                return;
            } else {
                if (values[0].equals(values[1])) {
                    count++;
                } else {
                    count = 0;
                }
            }
        }
        
        if (count >= 3) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}
