import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

class Pair {
    public int first;
    public int second;

    public Pair(int first, int second) {
        this.first = first;
        this.second = second;
    }
}

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        Queue<Pair> q = new LinkedList<Pair>();

        int n = scanner.nextInt();

        boolean doublet = false;

        for (int i = 0 ; i < n ; i++) {
            int d1 = scanner.nextInt();
            int d2 = scanner.nextInt();

            q.add(new Pair(d1,d2));
            if (q.size() >= 3) {
                int countDoublet = 0;
                for (Pair item: q) {
                    if (item.first == item.second) {
                        countDoublet++;
                    }
                }
                if (countDoublet == 3) {
                    doublet = true;
                    break;
                }
                q.remove();
            }
        }

        if (doublet) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
} import java.util.LinkedList; LinkedList java.util import java.util.Queue; Queue java.util import java.util.Scanner; Scanner java.util class Pair {
    public int first;
    public int second;

    public Pair(int first, int second) {
        this.first = first;
        this.second = second;
    }
} Pair public int first; first public int second; second public Pair(int first, int second) {
        this.first = first;
        this.second = second;
    } Pair {
        this.first = first;
        this.second = second;
    } this.first = first this.first this this.first first this.second = second this.second this this.second second int first first int second second public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        Queue<Pair> q = new LinkedList<Pair>();

        int n = scanner.nextInt();

        boolean doublet = false;

        for (int i = 0 ; i < n ; i++) {
            int d1 = scanner.nextInt();
            int d2 = scanner.nextInt();

            q.add(new Pair(d1,d2));
            if (q.size() >= 3) {
                int countDoublet = 0;
                for (Pair item: q) {
                    if (item.first == item.second) {
                        countDoublet++;
                    }
                }
                if (countDoublet == 3) {
                    doublet = true;
                    break;
                }
                q.remove();
            }
        }

        if (doublet) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
} Main public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        Queue<Pair> q = new LinkedList<Pair>();

        int n = scanner.nextInt();

        boolean doublet = false;

        for (int i = 0 ; i < n ; i++) {
            int d1 = scanner.nextInt();
            int d2 = scanner.nextInt();

            q.add(new Pair(d1,d2));
            if (q.size() >= 3) {
                int countDoublet = 0;
                for (Pair item: q) {
                    if (item.first == item.second) {
                        countDoublet++;
                    }
                }
                if (countDoublet == 3) {
                    doublet = true;
                    break;
                }
                q.remove();
            }
        }

        if (doublet) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    } main {
        Scanner scanner = new Scanner(System.in);

        Queue<Pair> q = new LinkedList<Pair>();

        int n = scanner.nextInt();

        boolean doublet = false;

        for (int i = 0 ; i < n ; i++) {
            int d1 = scanner.nextInt();
            int d2 = scanner.nextInt();

            q.add(new Pair(d1,d2));
            if (q.size() >= 3) {
                int countDoublet = 0;
                for (Pair item: q) {
                    if (item.first == item.second) {
                        countDoublet++;
                    }
                }
                if (countDoublet == 3) {
                    doublet = true;
                    break;
                }
                q.remove();
            }
        }

        if (doublet) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) Queue<Pair> q = new LinkedList<Pair>(); q new LinkedList<Pair>() int n = scanner.nextInt(); n scanner.nextInt() scanner.nextInt scanner boolean doublet = false; doublet false for (int i = 0 ; i < n ; i++) {
            int d1 = scanner.nextInt();
            int d2 = scanner.nextInt();

            q.add(new Pair(d1,d2));
            if (q.size() >= 3) {
                int countDoublet = 0;
                for (Pair item: q) {
                    if (item.first == item.second) {
                        countDoublet++;
                    }
                }
                if (countDoublet == 3) {
                    doublet = true;
                    break;
                }
                q.remove();
            }
        } int i = 0 ; int i = 0 ; i 0 i < n i n i++ i++ i {
            int d1 = scanner.nextInt();
            int d2 = scanner.nextInt();

            q.add(new Pair(d1,d2));
            if (q.size() >= 3) {
                int countDoublet = 0;
                for (Pair item: q) {
                    if (item.first == item.second) {
                        countDoublet++;
                    }
                }
                if (countDoublet == 3) {
                    doublet = true;
                    break;
                }
                q.remove();
            }
        } {
            int d1 = scanner.nextInt();
            int d2 = scanner.nextInt();

            q.add(new Pair(d1,d2));
            if (q.size() >= 3) {
                int countDoublet = 0;
                for (Pair item: q) {
                    if (item.first == item.second) {
                        countDoublet++;
                    }
                }
                if (countDoublet == 3) {
                    doublet = true;
                    break;
                }
                q.remove();
            }
        } int d1 = scanner.nextInt(); d1 scanner.nextInt() scanner.nextInt scanner int d2 = scanner.nextInt(); d2 scanner.nextInt() scanner.nextInt scanner q.add(new Pair(d1,d2)) q.add q new Pair(d1,d2) if (q.size() >= 3) {
                int countDoublet = 0;
                for (Pair item: q) {
                    if (item.first == item.second) {
                        countDoublet++;
                    }
                }
                if (countDoublet == 3) {
                    doublet = true;
                    break;
                }
                q.remove();
            } q.size() >= 3 q.size() q.size q 3 {
                int countDoublet = 0;
                for (Pair item: q) {
                    if (item.first == item.second) {
                        countDoublet++;
                    }
                }
                if (countDoublet == 3) {
                    doublet = true;
                    break;
                }
                q.remove();
            } int countDoublet = 0; countDoublet 0 for (Pair item: q) {
                    if (item.first == item.second) {
                        countDoublet++;
                    }
                } Pair item q {
                    if (item.first == item.second) {
                        countDoublet++;
                    }
                } {
                    if (item.first == item.second) {
                        countDoublet++;
                    }
                } if (item.first == item.second) {
                        countDoublet++;
                    } item.first == item.second item.first item item.first item.second item item.second {
                        countDoublet++;
                    } countDoublet++ countDoublet if (countDoublet == 3) {
                    doublet = true;
                    break;
                } countDoublet == 3 countDoublet 3 {
                    doublet = true;
                    break;
                } doublet = true doublet true break; q.remove() q.remove q if (doublet) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        } doublet {
            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) {
        Scanner scanner = new Scanner(System.in);

        Queue<Pair> q = new LinkedList<Pair>();

        int n = scanner.nextInt();

        boolean doublet = false;

        for (int i = 0 ; i < n ; i++) {
            int d1 = scanner.nextInt();
            int d2 = scanner.nextInt();

            q.add(new Pair(d1,d2));
            if (q.size() >= 3) {
                int countDoublet = 0;
                for (Pair item: q) {
                    if (item.first == item.second) {
                        countDoublet++;
                    }
                }
                if (countDoublet == 3) {
                    doublet = true;
                    break;
                }
                q.remove();
            }
        }

        if (doublet) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
} public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        Queue<Pair> q = new LinkedList<Pair>();

        int n = scanner.nextInt();

        boolean doublet = false;

        for (int i = 0 ; i < n ; i++) {
            int d1 = scanner.nextInt();
            int d2 = scanner.nextInt();

            q.add(new Pair(d1,d2));
            if (q.size() >= 3) {
                int countDoublet = 0;
                for (Pair item: q) {
                    if (item.first == item.second) {
                        countDoublet++;
                    }
                }
                if (countDoublet == 3) {
                    doublet = true;
                    break;
                }
                q.remove();
            }
        }

        if (doublet) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
} Main
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

class Pair {
    public int first;
    public int second;

    public Pair(int first, int second) {
        this.first = first;
        this.second = second;
    }
}

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        Queue<Pair> q = new LinkedList<Pair>();

        int n = scanner.nextInt();

        boolean doublet = false;

        for (int i = 0 ; i < n ; i++) {
            int d1 = scanner.nextInt();
            int d2 = scanner.nextInt();

            q.add(new Pair(d1,d2));
            if (q.size() >= 3) {
                int countDoublet = 0;
                for (Pair item: q) {
                    if (item.first == item.second) {
                        countDoublet++;
                    }
                }
                if (countDoublet == 3) {
                    doublet = true;
                    break;
                }
                q.remove();
            }
        }

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