import java.io.*;
import java.util.*;
class Main
{
  public static void main(String[] args)
  {
    Scanner sc = new Scanner(System.in);
    int maxcount = 0;
    int count=0;
    int N = sc.nextInt();
    if(N<3 || N>100)
    {
      System.exit(0);
    }
    int arr[][] = new int[N][2];
    for(int i=0; i<N; i++)
    {
      for(int j=0; j<2; j++)
      {
        arr[i][j]=sc.nextInt();
        if(arr[i][j] < 1 || arr[i][j] > 6)
          System.exit(0);
      }
    }
    for(int i = 0; i < N ; i++)
    {
      if(arr[i][0]==arr[i][1])
      {
        count++;    
      }
      else
      {
        count = 0;
      }
      maxcount = Math.max(maxcount,count);
    }
    if(maxcount>=3)
    {
      System.out.print("Yes");
    }
    else
    {
      System.out.print("No");
    }
  }
}
                        import java.io.*; io.* java import java.util.*; util.* java class Main
{
  public static void main(String[] args)
  {
    Scanner sc = new Scanner(System.in);
    int maxcount = 0;
    int count=0;
    int N = sc.nextInt();
    if(N<3 || N>100)
    {
      System.exit(0);
    }
    int arr[][] = new int[N][2];
    for(int i=0; i<N; i++)
    {
      for(int j=0; j<2; j++)
      {
        arr[i][j]=sc.nextInt();
        if(arr[i][j] < 1 || arr[i][j] > 6)
          System.exit(0);
      }
    }
    for(int i = 0; i < N ; i++)
    {
      if(arr[i][0]==arr[i][1])
      {
        count++;    
      }
      else
      {
        count = 0;
      }
      maxcount = Math.max(maxcount,count);
    }
    if(maxcount>=3)
    {
      System.out.print("Yes");
    }
    else
    {
      System.out.print("No");
    }
  }
} Main public static void main(String[] args)
  {
    Scanner sc = new Scanner(System.in);
    int maxcount = 0;
    int count=0;
    int N = sc.nextInt();
    if(N<3 || N>100)
    {
      System.exit(0);
    }
    int arr[][] = new int[N][2];
    for(int i=0; i<N; i++)
    {
      for(int j=0; j<2; j++)
      {
        arr[i][j]=sc.nextInt();
        if(arr[i][j] < 1 || arr[i][j] > 6)
          System.exit(0);
      }
    }
    for(int i = 0; i < N ; i++)
    {
      if(arr[i][0]==arr[i][1])
      {
        count++;    
      }
      else
      {
        count = 0;
      }
      maxcount = Math.max(maxcount,count);
    }
    if(maxcount>=3)
    {
      System.out.print("Yes");
    }
    else
    {
      System.out.print("No");
    }
  } main {
    Scanner sc = new Scanner(System.in);
    int maxcount = 0;
    int count=0;
    int N = sc.nextInt();
    if(N<3 || N>100)
    {
      System.exit(0);
    }
    int arr[][] = new int[N][2];
    for(int i=0; i<N; i++)
    {
      for(int j=0; j<2; j++)
      {
        arr[i][j]=sc.nextInt();
        if(arr[i][j] < 1 || arr[i][j] > 6)
          System.exit(0);
      }
    }
    for(int i = 0; i < N ; i++)
    {
      if(arr[i][0]==arr[i][1])
      {
        count++;    
      }
      else
      {
        count = 0;
      }
      maxcount = Math.max(maxcount,count);
    }
    if(maxcount>=3)
    {
      System.out.print("Yes");
    }
    else
    {
      System.out.print("No");
    }
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int maxcount = 0; maxcount 0 int count=0; count 0 int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc if(N<3 || N>100)
    {
      System.exit(0);
    } N<3 || N>100 N<3 N 3 N>100 N 100 {
      System.exit(0);
    } System.exit(0) System.exit System 0 int arr[][] = new int[N][2]; arr new int[N][2] N 2 for(int i=0; i<N; i++)
    {
      for(int j=0; j<2; j++)
      {
        arr[i][j]=sc.nextInt();
        if(arr[i][j] < 1 || arr[i][j] > 6)
          System.exit(0);
      }
    } int i=0; int i=0; i 0 i<N i N i++ i++ i {
      for(int j=0; j<2; j++)
      {
        arr[i][j]=sc.nextInt();
        if(arr[i][j] < 1 || arr[i][j] > 6)
          System.exit(0);
      }
    } {
      for(int j=0; j<2; j++)
      {
        arr[i][j]=sc.nextInt();
        if(arr[i][j] < 1 || arr[i][j] > 6)
          System.exit(0);
      }
    } for(int j=0; j<2; j++)
      {
        arr[i][j]=sc.nextInt();
        if(arr[i][j] < 1 || arr[i][j] > 6)
          System.exit(0);
      } int j=0; int j=0; j 0 j<2 j 2 j++ j++ j {
        arr[i][j]=sc.nextInt();
        if(arr[i][j] < 1 || arr[i][j] > 6)
          System.exit(0);
      } {
        arr[i][j]=sc.nextInt();
        if(arr[i][j] < 1 || arr[i][j] > 6)
          System.exit(0);
      } arr[i][j]=sc.nextInt() arr[i][j] arr[i] arr i j sc.nextInt() sc.nextInt sc if(arr[i][j] < 1 || arr[i][j] > 6)
          System.exit(0); arr[i][j] < 1 || arr[i][j] > 6 arr[i][j] < 1 arr[i][j] arr[i] arr i j 1 arr[i][j] > 6 arr[i][j] arr[i] arr i j 6 System.exit(0) System.exit System 0 for(int i = 0; i < N ; i++)
    {
      if(arr[i][0]==arr[i][1])
      {
        count++;    
      }
      else
      {
        count = 0;
      }
      maxcount = Math.max(maxcount,count);
    } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
      if(arr[i][0]==arr[i][1])
      {
        count++;    
      }
      else
      {
        count = 0;
      }
      maxcount = Math.max(maxcount,count);
    } {
      if(arr[i][0]==arr[i][1])
      {
        count++;    
      }
      else
      {
        count = 0;
      }
      maxcount = Math.max(maxcount,count);
    } if(arr[i][0]==arr[i][1])
      {
        count++;    
      }
      else
      {
        count = 0;
      } arr[i][0]==arr[i][1] arr[i][0] arr[i] arr i 0 arr[i][1] arr[i] arr i 1 {
        count++;    
      } count++ count {
        count = 0;
      } count = 0 count 0 maxcount = Math.max(maxcount,count) maxcount Math.max(maxcount,count) Math.max Math maxcount count if(maxcount>=3)
    {
      System.out.print("Yes");
    }
    else
    {
      System.out.print("No");
    } maxcount>=3 maxcount 3 {
      System.out.print("Yes");
    } System.out.print("Yes") System.out.print System.out System System.out "Yes" {
      System.out.print("No");
    } System.out.print("No") System.out.print System.out System System.out "No" String[] args args
import java.io.*;
import java.util.*;
class Main
{
  public static void main(String[] args)
  {
    Scanner sc = new Scanner(System.in);
    int maxcount = 0;
    int count=0;
    int N = sc.nextInt();
    if(N<3 || N>100)
    {
      System.exit(0);
    }
    int arr[][] = new int[N][2];
    for(int i=0; i<N; i++)
    {
      for(int j=0; j<2; j++)
      {
        arr[i][j]=sc.nextInt();
        if(arr[i][j] < 1 || arr[i][j] > 6)
          System.exit(0);
      }
    }
    for(int i = 0; i < N ; i++)
    {
      if(arr[i][0]==arr[i][1])
      {
        count++;    
      }
      else
      {
        count = 0;
      }
      maxcount = Math.max(maxcount,count);
    }
    if(maxcount>=3)
    {
      System.out.print("Yes");
    }
    else
    {
      System.out.print("No");
    }
  }
}
                       