import java.util.*;

/**
 * B Main
 *
 * @date 2020.09.19
 * @author 焼き鮭 <yaki-shake@up-tri.me>
 */

public class Main {
  Scanner sc;

  public static void main(String[] args) {
    new Main().execute();
  }

  public void execute() {
    this.sc = new Scanner(System.in);
    int n = sc.nextInt();

    int cnt = 0;
    for (int i = 0; i < n; i++) {
      int d0 = sc.nextInt();
      int d1 = sc.nextInt();
      if (d0 == d1) {
        cnt++;
        if (cnt >= 3) {
          System.out.println("Yes");
          return;
        }
      } else {
        cnt = 0;
      }
    }
    System.out.println("No");
  }
} import java.util.*; util.* java public class Main {
  Scanner sc;

  public static void main(String[] args) {
    new Main().execute();
  }

  public void execute() {
    this.sc = new Scanner(System.in);
    int n = sc.nextInt();

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

    int cnt = 0;
    for (int i = 0; i < n; i++) {
      int d0 = sc.nextInt();
      int d1 = sc.nextInt();
      if (d0 == d1) {
        cnt++;
        if (cnt >= 3) {
          System.out.println("Yes");
          return;
        }
      } else {
        cnt = 0;
      }
    }
    System.out.println("No");
  } execute {
    this.sc = new Scanner(System.in);
    int n = sc.nextInt();

    int cnt = 0;
    for (int i = 0; i < n; i++) {
      int d0 = sc.nextInt();
      int d1 = sc.nextInt();
      if (d0 == d1) {
        cnt++;
        if (cnt >= 3) {
          System.out.println("Yes");
          return;
        }
      } else {
        cnt = 0;
      }
    }
    System.out.println("No");
  } this.sc = new Scanner(System.in) this.sc this this.sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int cnt = 0; cnt 0 for (int i = 0; i < n; i++) {
      int d0 = sc.nextInt();
      int d1 = sc.nextInt();
      if (d0 == d1) {
        cnt++;
        if (cnt >= 3) {
          System.out.println("Yes");
          return;
        }
      } else {
        cnt = 0;
      }
    } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
      int d0 = sc.nextInt();
      int d1 = sc.nextInt();
      if (d0 == d1) {
        cnt++;
        if (cnt >= 3) {
          System.out.println("Yes");
          return;
        }
      } else {
        cnt = 0;
      }
    } {
      int d0 = sc.nextInt();
      int d1 = sc.nextInt();
      if (d0 == d1) {
        cnt++;
        if (cnt >= 3) {
          System.out.println("Yes");
          return;
        }
      } else {
        cnt = 0;
      }
    } int d0 = sc.nextInt(); d0 sc.nextInt() sc.nextInt sc int d1 = sc.nextInt(); d1 sc.nextInt() sc.nextInt sc if (d0 == d1) {
        cnt++;
        if (cnt >= 3) {
          System.out.println("Yes");
          return;
        }
      } else {
        cnt = 0;
      } d0 == d1 d0 d1 {
        cnt++;
        if (cnt >= 3) {
          System.out.println("Yes");
          return;
        }
      } cnt++ cnt if (cnt >= 3) {
          System.out.println("Yes");
          return;
        } cnt >= 3 cnt 3 {
          System.out.println("Yes");
          return;
        } System.out.println("Yes") System.out.println System.out System System.out "Yes" return; {
        cnt = 0;
      } cnt = 0 cnt 0 System.out.println("No") System.out.println System.out System System.out "No" public class Main {
  Scanner sc;

  public static void main(String[] args) {
    new Main().execute();
  }

  public void execute() {
    this.sc = new Scanner(System.in);
    int n = sc.nextInt();

    int cnt = 0;
    for (int i = 0; i < n; i++) {
      int d0 = sc.nextInt();
      int d1 = sc.nextInt();
      if (d0 == d1) {
        cnt++;
        if (cnt >= 3) {
          System.out.println("Yes");
          return;
        }
      } else {
        cnt = 0;
      }
    }
    System.out.println("No");
  }
} public class Main {
  Scanner sc;

  public static void main(String[] args) {
    new Main().execute();
  }

  public void execute() {
    this.sc = new Scanner(System.in);
    int n = sc.nextInt();

    int cnt = 0;
    for (int i = 0; i < n; i++) {
      int d0 = sc.nextInt();
      int d1 = sc.nextInt();
      if (d0 == d1) {
        cnt++;
        if (cnt >= 3) {
          System.out.println("Yes");
          return;
        }
      } else {
        cnt = 0;
      }
    }
    System.out.println("No");
  }
} Main
import java.util.*;

/**
 * B Main
 *
 * @date 2020.09.19
 * @author 焼き鮭 <yaki-shake@up-tri.me>
 */

public class Main {
  Scanner sc;

  public static void main(String[] args) {
    new Main().execute();
  }

  public void execute() {
    this.sc = new Scanner(System.in);
    int n = sc.nextInt();

    int cnt = 0;
    for (int i = 0; i < n; i++) {
      int d0 = sc.nextInt();
      int d1 = sc.nextInt();
      if (d0 == d1) {
        cnt++;
        if (cnt >= 3) {
          System.out.println("Yes");
          return;
        }
      } else {
        cnt = 0;
      }
    }
    System.out.println("No");
  }
}
