import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String ans = "No";
    int cnt = 0;
    for (int i = 0; i < n; i++) {
      if (sc.nextInt() == sc.nextInt()) {
        cnt++;
      } else {
        cnt = 0;
      }
      if (cnt >= 3) {
        ans = "Yes";
        break;
      }
    }
    System.out.println(ans);
  }
} import java.util.*; util.* java class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String ans = "No";
    int cnt = 0;
    for (int i = 0; i < n; i++) {
      if (sc.nextInt() == sc.nextInt()) {
        cnt++;
      } else {
        cnt = 0;
      }
      if (cnt >= 3) {
        ans = "Yes";
        break;
      }
    }
    System.out.println(ans);
  }
} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String ans = "No";
    int cnt = 0;
    for (int i = 0; i < n; i++) {
      if (sc.nextInt() == sc.nextInt()) {
        cnt++;
      } else {
        cnt = 0;
      }
      if (cnt >= 3) {
        ans = "Yes";
        break;
      }
    }
    System.out.println(ans);
  } main {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String ans = "No";
    int cnt = 0;
    for (int i = 0; i < n; i++) {
      if (sc.nextInt() == sc.nextInt()) {
        cnt++;
      } else {
        cnt = 0;
      }
      if (cnt >= 3) {
        ans = "Yes";
        break;
      }
    }
    System.out.println(ans);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc String ans = "No"; ans "No" int cnt = 0; cnt 0 for (int i = 0; i < n; i++) {
      if (sc.nextInt() == sc.nextInt()) {
        cnt++;
      } else {
        cnt = 0;
      }
      if (cnt >= 3) {
        ans = "Yes";
        break;
      }
    } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
      if (sc.nextInt() == sc.nextInt()) {
        cnt++;
      } else {
        cnt = 0;
      }
      if (cnt >= 3) {
        ans = "Yes";
        break;
      }
    } {
      if (sc.nextInt() == sc.nextInt()) {
        cnt++;
      } else {
        cnt = 0;
      }
      if (cnt >= 3) {
        ans = "Yes";
        break;
      }
    } if (sc.nextInt() == sc.nextInt()) {
        cnt++;
      } else {
        cnt = 0;
      } sc.nextInt() == sc.nextInt() sc.nextInt() sc.nextInt sc sc.nextInt() sc.nextInt sc {
        cnt++;
      } cnt++ cnt {
        cnt = 0;
      } cnt = 0 cnt 0 if (cnt >= 3) {
        ans = "Yes";
        break;
      } cnt >= 3 cnt 3 {
        ans = "Yes";
        break;
      } ans = "Yes" ans "Yes" break; System.out.println(ans) System.out.println System.out System System.out ans String[] args args
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String ans = "No";
    int cnt = 0;
    for (int i = 0; i < n; i++) {
      if (sc.nextInt() == sc.nextInt()) {
        cnt++;
      } else {
        cnt = 0;
      }
      if (cnt >= 3) {
        ans = "Yes";
        break;
      }
    }
    System.out.println(ans);
  }
}