import java.io.*;
public class Main{
  public static void main(String args[])throws IOException
  {
   BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
    int n=Integer.parseInt(br.readLine());
    int i,c=0,flag=0;
    String s="";
    for(i=0;i<n;i++)
    {
      s=br.readLine();
      if(s.charAt(0)==(s.charAt(2))){
        c++;
        if(c>2){
        flag=1;
        break;}
      }
      else
        c=0;
      
    }
    if(flag==1)
      System.out.println("Yes");
    else
      System.out.println("No");
  }
} import java.io.*; io.* java public class Main{
  public static void main(String args[])throws IOException
  {
   BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
    int n=Integer.parseInt(br.readLine());
    int i,c=0,flag=0;
    String s="";
    for(i=0;i<n;i++)
    {
      s=br.readLine();
      if(s.charAt(0)==(s.charAt(2))){
        c++;
        if(c>2){
        flag=1;
        break;}
      }
      else
        c=0;
      
    }
    if(flag==1)
      System.out.println("Yes");
    else
      System.out.println("No");
  }
} Main public static void main(String args[])throws IOException
  {
   BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
    int n=Integer.parseInt(br.readLine());
    int i,c=0,flag=0;
    String s="";
    for(i=0;i<n;i++)
    {
      s=br.readLine();
      if(s.charAt(0)==(s.charAt(2))){
        c++;
        if(c>2){
        flag=1;
        break;}
      }
      else
        c=0;
      
    }
    if(flag==1)
      System.out.println("Yes");
    else
      System.out.println("No");
  } main {
   BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
    int n=Integer.parseInt(br.readLine());
    int i,c=0,flag=0;
    String s="";
    for(i=0;i<n;i++)
    {
      s=br.readLine();
      if(s.charAt(0)==(s.charAt(2))){
        c++;
        if(c>2){
        flag=1;
        break;}
      }
      else
        c=0;
      
    }
    if(flag==1)
      System.out.println("Yes");
    else
      System.out.println("No");
  } BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) int n=Integer.parseInt(br.readLine()); n Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br int i i c=0 c 0 flag=0; flag 0 String s=""; s "" for(i=0;i<n;i++)
    {
      s=br.readLine();
      if(s.charAt(0)==(s.charAt(2))){
        c++;
        if(c>2){
        flag=1;
        break;}
      }
      else
        c=0;
      
    } i=0; i=0 i 0 i<n i n i++ i++ i {
      s=br.readLine();
      if(s.charAt(0)==(s.charAt(2))){
        c++;
        if(c>2){
        flag=1;
        break;}
      }
      else
        c=0;
      
    } {
      s=br.readLine();
      if(s.charAt(0)==(s.charAt(2))){
        c++;
        if(c>2){
        flag=1;
        break;}
      }
      else
        c=0;
      
    } s=br.readLine() s br.readLine() br.readLine br if(s.charAt(0)==(s.charAt(2))){
        c++;
        if(c>2){
        flag=1;
        break;}
      }
      else
        c=0; s.charAt(0)==(s.charAt(2)) s.charAt(0) s.charAt s 0 (s.charAt(2)) s.charAt s 2 {
        c++;
        if(c>2){
        flag=1;
        break;}
      } c++ c if(c>2){
        flag=1;
        break;} c>2 c 2 {
        flag=1;
        break;} flag=1 flag 1 break; c=0 c 0 if(flag==1)
      System.out.println("Yes");
    else
      System.out.println("No"); flag==1 flag 1 System.out.println("Yes") System.out.println System.out System System.out "Yes" 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[])throws IOException
  {
   BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
    int n=Integer.parseInt(br.readLine());
    int i,c=0,flag=0;
    String s="";
    for(i=0;i<n;i++)
    {
      s=br.readLine();
      if(s.charAt(0)==(s.charAt(2))){
        c++;
        if(c>2){
        flag=1;
        break;}
      }
      else
        c=0;
      
    }
    if(flag==1)
      System.out.println("Yes");
    else
      System.out.println("No");
  }
} public class Main{
  public static void main(String args[])throws IOException
  {
   BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
    int n=Integer.parseInt(br.readLine());
    int i,c=0,flag=0;
    String s="";
    for(i=0;i<n;i++)
    {
      s=br.readLine();
      if(s.charAt(0)==(s.charAt(2))){
        c++;
        if(c>2){
        flag=1;
        break;}
      }
      else
        c=0;
      
    }
    if(flag==1)
      System.out.println("Yes");
    else
      System.out.println("No");
  }
} Main
import java.io.*;
public class Main{
  public static void main(String args[])throws IOException
  {
   BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
    int n=Integer.parseInt(br.readLine());
    int i,c=0,flag=0;
    String s="";
    for(i=0;i<n;i++)
    {
      s=br.readLine();
      if(s.charAt(0)==(s.charAt(2))){
        c++;
        if(c>2){
        flag=1;
        break;}
      }
      else
        c=0;
      
    }
    if(flag==1)
      System.out.println("Yes");
    else
      System.out.println("No");
  }
}