import java.util.Scanner;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import java.util.HashSet;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N=sc.nextInt();
   int D1[]=new int[N];
   int D2[]=new int[N];
   int count=0;
  for (int k=0;k<N ;k++ ) {
    D1[k]=sc.nextInt();
    D2[k]=sc.nextInt();
  }
for (int n=0;n<N ;n++ ) {
  if (count==3) {
    break;
  }
  if (D1[n]==D2[n]) {
    count++;
  }else{
    count=0;
  }
}
if(count==3){
  System.out.println("Yes");

}else{
  System.out.println("No");
}

}
} import java.util.Scanner; Scanner java.util import java.util.Arrays; Arrays java.util import java.util.ArrayList; ArrayList java.util import java.util.List; List java.util import java.util.stream.Collectors; Collectors java.util.stream import java.util.HashSet; HashSet java.util class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N=sc.nextInt();
   int D1[]=new int[N];
   int D2[]=new int[N];
   int count=0;
  for (int k=0;k<N ;k++ ) {
    D1[k]=sc.nextInt();
    D2[k]=sc.nextInt();
  }
for (int n=0;n<N ;n++ ) {
  if (count==3) {
    break;
  }
  if (D1[n]==D2[n]) {
    count++;
  }else{
    count=0;
  }
}
if(count==3){
  System.out.println("Yes");

}else{
  System.out.println("No");
}

}
} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N=sc.nextInt();
   int D1[]=new int[N];
   int D2[]=new int[N];
   int count=0;
  for (int k=0;k<N ;k++ ) {
    D1[k]=sc.nextInt();
    D2[k]=sc.nextInt();
  }
for (int n=0;n<N ;n++ ) {
  if (count==3) {
    break;
  }
  if (D1[n]==D2[n]) {
    count++;
  }else{
    count=0;
  }
}
if(count==3){
  System.out.println("Yes");

}else{
  System.out.println("No");
}

} main {
    Scanner sc = new Scanner(System.in);
    int N=sc.nextInt();
   int D1[]=new int[N];
   int D2[]=new int[N];
   int count=0;
  for (int k=0;k<N ;k++ ) {
    D1[k]=sc.nextInt();
    D2[k]=sc.nextInt();
  }
for (int n=0;n<N ;n++ ) {
  if (count==3) {
    break;
  }
  if (D1[n]==D2[n]) {
    count++;
  }else{
    count=0;
  }
}
if(count==3){
  System.out.println("Yes");

}else{
  System.out.println("No");
}

} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N=sc.nextInt(); N sc.nextInt() sc.nextInt sc int D1[]=new int[N]; D1 new int[N] N int D2[]=new int[N]; D2 new int[N] N int count=0; count 0 for (int k=0;k<N ;k++ ) {
    D1[k]=sc.nextInt();
    D2[k]=sc.nextInt();
  } int k=0; int k=0; k 0 k<N k N k++ k++ k {
    D1[k]=sc.nextInt();
    D2[k]=sc.nextInt();
  } {
    D1[k]=sc.nextInt();
    D2[k]=sc.nextInt();
  } D1[k]=sc.nextInt() D1[k] D1 k sc.nextInt() sc.nextInt sc D2[k]=sc.nextInt() D2[k] D2 k sc.nextInt() sc.nextInt sc for (int n=0;n<N ;n++ ) {
  if (count==3) {
    break;
  }
  if (D1[n]==D2[n]) {
    count++;
  }else{
    count=0;
  }
} int n=0; int n=0; n 0 n<N n N n++ n++ n {
  if (count==3) {
    break;
  }
  if (D1[n]==D2[n]) {
    count++;
  }else{
    count=0;
  }
} {
  if (count==3) {
    break;
  }
  if (D1[n]==D2[n]) {
    count++;
  }else{
    count=0;
  }
} if (count==3) {
    break;
  } count==3 count 3 {
    break;
  } break; if (D1[n]==D2[n]) {
    count++;
  }else{
    count=0;
  } D1[n]==D2[n] D1[n] D1 n D2[n] D2 n {
    count++;
  } count++ count {
    count=0;
  } count=0 count 0 if(count==3){
  System.out.println("Yes");

}else{
  System.out.println("No");
} count==3 count 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
import java.util.Scanner;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import java.util.HashSet;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N=sc.nextInt();
   int D1[]=new int[N];
   int D2[]=new int[N];
   int count=0;
  for (int k=0;k<N ;k++ ) {
    D1[k]=sc.nextInt();
    D2[k]=sc.nextInt();
  }
for (int n=0;n<N ;n++ ) {
  if (count==3) {
    break;
  }
  if (D1[n]==D2[n]) {
    count++;
  }else{
    count=0;
  }
}
if(count==3){
  System.out.println("Yes");

}else{
  System.out.println("No");
}

}
}
