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

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int n = Integer.parseInt(sc.next());
    int count = 0;
    for (int i = 0; i < n; i++) {
      int d1 = Integer.parseInt(sc.next());
      int d2 = Integer.parseInt(sc.next());
      if (d1 == d2) {
        count++;
      } else {
        count = 0;
      }
      if (count == 3) {
        pw.println("Yes");
        return;
      }
    }
    pw.println("No");
  }
} import java.io.InputStream; InputStream java.io import java.io.PrintStream; PrintStream java.io import java.util.Scanner; Scanner java.util public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int n = Integer.parseInt(sc.next());
    int count = 0;
    for (int i = 0; i < n; i++) {
      int d1 = Integer.parseInt(sc.next());
      int d2 = Integer.parseInt(sc.next());
      if (d1 == d2) {
        count++;
      } else {
        count = 0;
      }
      if (count == 3) {
        pw.println("Yes");
        return;
      }
    }
    pw.println("No");
  }
} Main public static void main(String[] args) {
    resolve(System.in, System.out);
  } main {
    resolve(System.in, System.out);
  } resolve(System.in, System.out) resolve System.in System System.in System.out System System.out String[] args args static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int n = Integer.parseInt(sc.next());
    int count = 0;
    for (int i = 0; i < n; i++) {
      int d1 = Integer.parseInt(sc.next());
      int d2 = Integer.parseInt(sc.next());
      if (d1 == d2) {
        count++;
      } else {
        count = 0;
      }
      if (count == 3) {
        pw.println("Yes");
        return;
      }
    }
    pw.println("No");
  } resolve {
    Scanner sc = new Scanner(is);
    int n = Integer.parseInt(sc.next());
    int count = 0;
    for (int i = 0; i < n; i++) {
      int d1 = Integer.parseInt(sc.next());
      int d2 = Integer.parseInt(sc.next());
      if (d1 == d2) {
        count++;
      } else {
        count = 0;
      }
      if (count == 3) {
        pw.println("Yes");
        return;
      }
    }
    pw.println("No");
  } Scanner sc = new Scanner(is); sc new Scanner(is) int n = Integer.parseInt(sc.next()); n Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int count = 0; count 0 for (int i = 0; i < n; i++) {
      int d1 = Integer.parseInt(sc.next());
      int d2 = Integer.parseInt(sc.next());
      if (d1 == d2) {
        count++;
      } else {
        count = 0;
      }
      if (count == 3) {
        pw.println("Yes");
        return;
      }
    } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
      int d1 = Integer.parseInt(sc.next());
      int d2 = Integer.parseInt(sc.next());
      if (d1 == d2) {
        count++;
      } else {
        count = 0;
      }
      if (count == 3) {
        pw.println("Yes");
        return;
      }
    } {
      int d1 = Integer.parseInt(sc.next());
      int d2 = Integer.parseInt(sc.next());
      if (d1 == d2) {
        count++;
      } else {
        count = 0;
      }
      if (count == 3) {
        pw.println("Yes");
        return;
      }
    } int d1 = Integer.parseInt(sc.next()); d1 Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int d2 = Integer.parseInt(sc.next()); d2 Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc if (d1 == d2) {
        count++;
      } else {
        count = 0;
      } d1 == d2 d1 d2 {
        count++;
      } count++ count {
        count = 0;
      } count = 0 count 0 if (count == 3) {
        pw.println("Yes");
        return;
      } count == 3 count 3 {
        pw.println("Yes");
        return;
      } pw.println("Yes") pw.println pw "Yes" return; pw.println("No") pw.println pw "No" InputStream is is PrintStream pw pw public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int n = Integer.parseInt(sc.next());
    int count = 0;
    for (int i = 0; i < n; i++) {
      int d1 = Integer.parseInt(sc.next());
      int d2 = Integer.parseInt(sc.next());
      if (d1 == d2) {
        count++;
      } else {
        count = 0;
      }
      if (count == 3) {
        pw.println("Yes");
        return;
      }
    }
    pw.println("No");
  }
} public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int n = Integer.parseInt(sc.next());
    int count = 0;
    for (int i = 0; i < n; i++) {
      int d1 = Integer.parseInt(sc.next());
      int d2 = Integer.parseInt(sc.next());
      if (d1 == d2) {
        count++;
      } else {
        count = 0;
      }
      if (count == 3) {
        pw.println("Yes");
        return;
      }
    }
    pw.println("No");
  }
} Main
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int n = Integer.parseInt(sc.next());
    int count = 0;
    for (int i = 0; i < n; i++) {
      int d1 = Integer.parseInt(sc.next());
      int d2 = Integer.parseInt(sc.next());
      if (d1 == d2) {
        count++;
      } else {
        count = 0;
      }
      if (count == 3) {
        pw.println("Yes");
        return;
      }
    }
    pw.println("No");
  }
}
