
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        int N = scan.nextInt();
        boolean first = false;
        boolean second = false;
        for(int i = 0; i < N; i++) {
            int D1 = scan.nextInt();
            int D2 = scan.nextInt();
            if(!first) {
                if(D1 == D2)
                    first = true;
            } else if (!second) {
                if(D1 == D2)
                    second = true;
                else
                    first = false;
            } else {
                if(D1 == D2) {
                    os.println("Yes");
                    return;
                } else {
                    first = false;
                    second = false;
                }
            }
        }


        os.println("No");
    }
} import java.io.InputStream; InputStream java.io import java.io.PrintStream; PrintStream java.io import java.util.*; util.* java public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        int N = scan.nextInt();
        boolean first = false;
        boolean second = false;
        for(int i = 0; i < N; i++) {
            int D1 = scan.nextInt();
            int D2 = scan.nextInt();
            if(!first) {
                if(D1 == D2)
                    first = true;
            } else if (!second) {
                if(D1 == D2)
                    second = true;
                else
                    first = false;
            } else {
                if(D1 == D2) {
                    os.println("Yes");
                    return;
                } else {
                    first = false;
                    second = false;
                }
            }
        }


        os.println("No");
    }
} Main public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    } main {
        solve(System.in, System.out);
    } solve(System.in, System.out) solve System.in System System.in System.out System System.out String[] args args static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        int N = scan.nextInt();
        boolean first = false;
        boolean second = false;
        for(int i = 0; i < N; i++) {
            int D1 = scan.nextInt();
            int D2 = scan.nextInt();
            if(!first) {
                if(D1 == D2)
                    first = true;
            } else if (!second) {
                if(D1 == D2)
                    second = true;
                else
                    first = false;
            } else {
                if(D1 == D2) {
                    os.println("Yes");
                    return;
                } else {
                    first = false;
                    second = false;
                }
            }
        }


        os.println("No");
    } solve {
        // Your code here!
        Scanner scan = new Scanner(is);
        int N = scan.nextInt();
        boolean first = false;
        boolean second = false;
        for(int i = 0; i < N; i++) {
            int D1 = scan.nextInt();
            int D2 = scan.nextInt();
            if(!first) {
                if(D1 == D2)
                    first = true;
            } else if (!second) {
                if(D1 == D2)
                    second = true;
                else
                    first = false;
            } else {
                if(D1 == D2) {
                    os.println("Yes");
                    return;
                } else {
                    first = false;
                    second = false;
                }
            }
        }


        os.println("No");
    } Scanner scan = new Scanner(is); scan new Scanner(is) int N = scan.nextInt(); N scan.nextInt() scan.nextInt scan boolean first = false; first false boolean second = false; second false for(int i = 0; i < N; i++) {
            int D1 = scan.nextInt();
            int D2 = scan.nextInt();
            if(!first) {
                if(D1 == D2)
                    first = true;
            } else if (!second) {
                if(D1 == D2)
                    second = true;
                else
                    first = false;
            } else {
                if(D1 == D2) {
                    os.println("Yes");
                    return;
                } else {
                    first = false;
                    second = false;
                }
            }
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            int D1 = scan.nextInt();
            int D2 = scan.nextInt();
            if(!first) {
                if(D1 == D2)
                    first = true;
            } else if (!second) {
                if(D1 == D2)
                    second = true;
                else
                    first = false;
            } else {
                if(D1 == D2) {
                    os.println("Yes");
                    return;
                } else {
                    first = false;
                    second = false;
                }
            }
        } {
            int D1 = scan.nextInt();
            int D2 = scan.nextInt();
            if(!first) {
                if(D1 == D2)
                    first = true;
            } else if (!second) {
                if(D1 == D2)
                    second = true;
                else
                    first = false;
            } else {
                if(D1 == D2) {
                    os.println("Yes");
                    return;
                } else {
                    first = false;
                    second = false;
                }
            }
        } int D1 = scan.nextInt(); D1 scan.nextInt() scan.nextInt scan int D2 = scan.nextInt(); D2 scan.nextInt() scan.nextInt scan if(!first) {
                if(D1 == D2)
                    first = true;
            } else if (!second) {
                if(D1 == D2)
                    second = true;
                else
                    first = false;
            } else {
                if(D1 == D2) {
                    os.println("Yes");
                    return;
                } else {
                    first = false;
                    second = false;
                }
            } !first first {
                if(D1 == D2)
                    first = true;
            } if(D1 == D2)
                    first = true; D1 == D2 D1 D2 first = true first true if (!second) {
                if(D1 == D2)
                    second = true;
                else
                    first = false;
            } else {
                if(D1 == D2) {
                    os.println("Yes");
                    return;
                } else {
                    first = false;
                    second = false;
                }
            } !second second {
                if(D1 == D2)
                    second = true;
                else
                    first = false;
            } if(D1 == D2)
                    second = true;
                else
                    first = false; D1 == D2 D1 D2 second = true second true first = false first false {
                if(D1 == D2) {
                    os.println("Yes");
                    return;
                } else {
                    first = false;
                    second = false;
                }
            } if(D1 == D2) {
                    os.println("Yes");
                    return;
                } else {
                    first = false;
                    second = false;
                } D1 == D2 D1 D2 {
                    os.println("Yes");
                    return;
                } os.println("Yes") os.println os "Yes" return; {
                    first = false;
                    second = false;
                } first = false first false second = false second false os.println("No") os.println os "No" InputStream is is PrintStream os os public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        int N = scan.nextInt();
        boolean first = false;
        boolean second = false;
        for(int i = 0; i < N; i++) {
            int D1 = scan.nextInt();
            int D2 = scan.nextInt();
            if(!first) {
                if(D1 == D2)
                    first = true;
            } else if (!second) {
                if(D1 == D2)
                    second = true;
                else
                    first = false;
            } else {
                if(D1 == D2) {
                    os.println("Yes");
                    return;
                } else {
                    first = false;
                    second = false;
                }
            }
        }


        os.println("No");
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        int N = scan.nextInt();
        boolean first = false;
        boolean second = false;
        for(int i = 0; i < N; i++) {
            int D1 = scan.nextInt();
            int D2 = scan.nextInt();
            if(!first) {
                if(D1 == D2)
                    first = true;
            } else if (!second) {
                if(D1 == D2)
                    second = true;
                else
                    first = false;
            } else {
                if(D1 == D2) {
                    os.println("Yes");
                    return;
                } else {
                    first = false;
                    second = false;
                }
            }
        }


        os.println("No");
    }
} Main

import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        int N = scan.nextInt();
        boolean first = false;
        boolean second = false;
        for(int i = 0; i < N; i++) {
            int D1 = scan.nextInt();
            int D2 = scan.nextInt();
            if(!first) {
                if(D1 == D2)
                    first = true;
            } else if (!second) {
                if(D1 == D2)
                    second = true;
                else
                    first = false;
            } else {
                if(D1 == D2) {
                    os.println("Yes");
                    return;
                } else {
                    first = false;
                    second = false;
                }
            }
        }


        os.println("No");
    }
}