import java.util.Scanner;

public class Main { 
  public static void main(String[] args) {

    int count = 0;
    int max = 0;
    int D1 = 0;
    int D2 = 0; 

    Scanner scanner = new Scanner(System.in);
    int N = Integer.parseInt(scanner.next());
    for (int i = 0; i < N; i++){
      D1 = Integer.parseInt(scanner.next());
      D2 = Integer.parseInt(scanner.next());
      if (D1 == D2) {
        count++;
        if (count == N){
          max = count;
        }
      } else {
        if (count > max){
          max = count;
        }
        count = 0;
      }
    }
    scanner.close();

    if (max >= 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) {

    int count = 0;
    int max = 0;
    int D1 = 0;
    int D2 = 0; 

    Scanner scanner = new Scanner(System.in);
    int N = Integer.parseInt(scanner.next());
    for (int i = 0; i < N; i++){
      D1 = Integer.parseInt(scanner.next());
      D2 = Integer.parseInt(scanner.next());
      if (D1 == D2) {
        count++;
        if (count == N){
          max = count;
        }
      } else {
        if (count > max){
          max = count;
        }
        count = 0;
      }
    }
    scanner.close();

    if (max >= 3){
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
} Main public static void main(String[] args) {

    int count = 0;
    int max = 0;
    int D1 = 0;
    int D2 = 0; 

    Scanner scanner = new Scanner(System.in);
    int N = Integer.parseInt(scanner.next());
    for (int i = 0; i < N; i++){
      D1 = Integer.parseInt(scanner.next());
      D2 = Integer.parseInt(scanner.next());
      if (D1 == D2) {
        count++;
        if (count == N){
          max = count;
        }
      } else {
        if (count > max){
          max = count;
        }
        count = 0;
      }
    }
    scanner.close();

    if (max >= 3){
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  } main {

    int count = 0;
    int max = 0;
    int D1 = 0;
    int D2 = 0; 

    Scanner scanner = new Scanner(System.in);
    int N = Integer.parseInt(scanner.next());
    for (int i = 0; i < N; i++){
      D1 = Integer.parseInt(scanner.next());
      D2 = Integer.parseInt(scanner.next());
      if (D1 == D2) {
        count++;
        if (count == N){
          max = count;
        }
      } else {
        if (count > max){
          max = count;
        }
        count = 0;
      }
    }
    scanner.close();

    if (max >= 3){
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  } int count = 0; count 0 int max = 0; max 0 int D1 = 0; D1 0 int D2 = 0; D2 0 Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int N = Integer.parseInt(scanner.next()); N Integer.parseInt(scanner.next()) Integer.parseInt Integer scanner.next() scanner.next scanner for (int i = 0; i < N; i++){
      D1 = Integer.parseInt(scanner.next());
      D2 = Integer.parseInt(scanner.next());
      if (D1 == D2) {
        count++;
        if (count == N){
          max = count;
        }
      } else {
        if (count > max){
          max = count;
        }
        count = 0;
      }
    } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
      D1 = Integer.parseInt(scanner.next());
      D2 = Integer.parseInt(scanner.next());
      if (D1 == D2) {
        count++;
        if (count == N){
          max = count;
        }
      } else {
        if (count > max){
          max = count;
        }
        count = 0;
      }
    } {
      D1 = Integer.parseInt(scanner.next());
      D2 = Integer.parseInt(scanner.next());
      if (D1 == D2) {
        count++;
        if (count == N){
          max = count;
        }
      } else {
        if (count > max){
          max = count;
        }
        count = 0;
      }
    } D1 = Integer.parseInt(scanner.next()) D1 Integer.parseInt(scanner.next()) Integer.parseInt Integer scanner.next() scanner.next scanner D2 = Integer.parseInt(scanner.next()) D2 Integer.parseInt(scanner.next()) Integer.parseInt Integer scanner.next() scanner.next scanner if (D1 == D2) {
        count++;
        if (count == N){
          max = count;
        }
      } else {
        if (count > max){
          max = count;
        }
        count = 0;
      } D1 == D2 D1 D2 {
        count++;
        if (count == N){
          max = count;
        }
      } count++ count if (count == N){
          max = count;
        } count == N count N {
          max = count;
        } max = count max count {
        if (count > max){
          max = count;
        }
        count = 0;
      } if (count > max){
          max = count;
        } count > max count max {
          max = count;
        } max = count max count count = 0 count 0 scanner.close() scanner.close scanner if (max >= 3){
      System.out.println("Yes");
    } else {
      System.out.println("No");
    } max >= 3 max 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) {

    int count = 0;
    int max = 0;
    int D1 = 0;
    int D2 = 0; 

    Scanner scanner = new Scanner(System.in);
    int N = Integer.parseInt(scanner.next());
    for (int i = 0; i < N; i++){
      D1 = Integer.parseInt(scanner.next());
      D2 = Integer.parseInt(scanner.next());
      if (D1 == D2) {
        count++;
        if (count == N){
          max = count;
        }
      } else {
        if (count > max){
          max = count;
        }
        count = 0;
      }
    }
    scanner.close();

    if (max >= 3){
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
} public class Main { 
  public static void main(String[] args) {

    int count = 0;
    int max = 0;
    int D1 = 0;
    int D2 = 0; 

    Scanner scanner = new Scanner(System.in);
    int N = Integer.parseInt(scanner.next());
    for (int i = 0; i < N; i++){
      D1 = Integer.parseInt(scanner.next());
      D2 = Integer.parseInt(scanner.next());
      if (D1 == D2) {
        count++;
        if (count == N){
          max = count;
        }
      } else {
        if (count > max){
          max = count;
        }
        count = 0;
      }
    }
    scanner.close();

    if (max >= 3){
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
} Main
import java.util.Scanner;

public class Main { 
  public static void main(String[] args) {

    int count = 0;
    int max = 0;
    int D1 = 0;
    int D2 = 0; 

    Scanner scanner = new Scanner(System.in);
    int N = Integer.parseInt(scanner.next());
    for (int i = 0; i < N; i++){
      D1 = Integer.parseInt(scanner.next());
      D2 = Integer.parseInt(scanner.next());
      if (D1 == D2) {
        count++;
        if (count == N){
          max = count;
        }
      } else {
        if (count > max){
          max = count;
        }
        count = 0;
      }
    }
    scanner.close();

    if (max >= 3){
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

