import java.util.Arrays;
import java.util.Scanner;
import java.util.Vector;
 
public class Main {
	
	public static void main(String[] args) {
		Scanner ob=new Scanner(System.in);
		int n=ob.nextInt();
		String s="";
		for (int i=0; i<n; i++) {
			char c1=ob.next().charAt(0);
			s=s+c1;
			char c2=ob.next().charAt(0);
			s=s+c2;
		}
		for(int i=0;i<=s.length()-6;i+=2)
		{
		if((s.charAt(i)==s.charAt(i+1))&&(s.charAt(i+2)==s.charAt(i+3))&&(s.charAt(i+4)==s.charAt(i+5)))
		{System.out.println("Yes");System.exit(0);}
		}
		System.out.println("No");
	}
} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util import java.util.Vector; Vector java.util public class Main {
	
	public static void main(String[] args) {
		Scanner ob=new Scanner(System.in);
		int n=ob.nextInt();
		String s="";
		for (int i=0; i<n; i++) {
			char c1=ob.next().charAt(0);
			s=s+c1;
			char c2=ob.next().charAt(0);
			s=s+c2;
		}
		for(int i=0;i<=s.length()-6;i+=2)
		{
		if((s.charAt(i)==s.charAt(i+1))&&(s.charAt(i+2)==s.charAt(i+3))&&(s.charAt(i+4)==s.charAt(i+5)))
		{System.out.println("Yes");System.exit(0);}
		}
		System.out.println("No");
	}
} Main public static void main(String[] args) {
		Scanner ob=new Scanner(System.in);
		int n=ob.nextInt();
		String s="";
		for (int i=0; i<n; i++) {
			char c1=ob.next().charAt(0);
			s=s+c1;
			char c2=ob.next().charAt(0);
			s=s+c2;
		}
		for(int i=0;i<=s.length()-6;i+=2)
		{
		if((s.charAt(i)==s.charAt(i+1))&&(s.charAt(i+2)==s.charAt(i+3))&&(s.charAt(i+4)==s.charAt(i+5)))
		{System.out.println("Yes");System.exit(0);}
		}
		System.out.println("No");
	} main {
		Scanner ob=new Scanner(System.in);
		int n=ob.nextInt();
		String s="";
		for (int i=0; i<n; i++) {
			char c1=ob.next().charAt(0);
			s=s+c1;
			char c2=ob.next().charAt(0);
			s=s+c2;
		}
		for(int i=0;i<=s.length()-6;i+=2)
		{
		if((s.charAt(i)==s.charAt(i+1))&&(s.charAt(i+2)==s.charAt(i+3))&&(s.charAt(i+4)==s.charAt(i+5)))
		{System.out.println("Yes");System.exit(0);}
		}
		System.out.println("No");
	} Scanner ob=new Scanner(System.in); ob new Scanner(System.in) int n=ob.nextInt(); n ob.nextInt() ob.nextInt ob String s=""; s "" for (int i=0; i<n; i++) {
			char c1=ob.next().charAt(0);
			s=s+c1;
			char c2=ob.next().charAt(0);
			s=s+c2;
		} int i=0; int i=0; i 0 i<n i n i++ i++ i {
			char c1=ob.next().charAt(0);
			s=s+c1;
			char c2=ob.next().charAt(0);
			s=s+c2;
		} {
			char c1=ob.next().charAt(0);
			s=s+c1;
			char c2=ob.next().charAt(0);
			s=s+c2;
		} char c1=ob.next().charAt(0); c1 ob.next().charAt(0) ob.next().charAt ob.next() ob.next ob 0 s=s+c1 s s+c1 s c1 char c2=ob.next().charAt(0); c2 ob.next().charAt(0) ob.next().charAt ob.next() ob.next ob 0 s=s+c2 s s+c2 s c2 for(int i=0;i<=s.length()-6;i+=2)
		{
		if((s.charAt(i)==s.charAt(i+1))&&(s.charAt(i+2)==s.charAt(i+3))&&(s.charAt(i+4)==s.charAt(i+5)))
		{System.out.println("Yes");System.exit(0);}
		} int i=0; int i=0; i 0 i<=s.length()-6 i s.length()-6 s.length() s.length s 6 i+=2 i+=2 i 2 {
		if((s.charAt(i)==s.charAt(i+1))&&(s.charAt(i+2)==s.charAt(i+3))&&(s.charAt(i+4)==s.charAt(i+5)))
		{System.out.println("Yes");System.exit(0);}
		} {
		if((s.charAt(i)==s.charAt(i+1))&&(s.charAt(i+2)==s.charAt(i+3))&&(s.charAt(i+4)==s.charAt(i+5)))
		{System.out.println("Yes");System.exit(0);}
		} if((s.charAt(i)==s.charAt(i+1))&&(s.charAt(i+2)==s.charAt(i+3))&&(s.charAt(i+4)==s.charAt(i+5)))
		{System.out.println("Yes");System.exit(0);} (s.charAt(i)==s.charAt(i+1))&&(s.charAt(i+2)==s.charAt(i+3))&&(s.charAt(i+4)==s.charAt(i+5)) (s.charAt(i)==s.charAt(i+1))&&(s.charAt(i+2)==s.charAt(i+3))&&(s.charAt(i+4)==s.charAt(i+5)) (s.charAt(i)==s.charAt(i+1)) s.charAt(i) s.charAt s i s.charAt(i+1) s.charAt s i+1 i 1 (s.charAt(i+2)==s.charAt(i+3)) s.charAt(i+2) s.charAt s i+2 i 2 s.charAt(i+3) s.charAt s i+3 i 3 (s.charAt(i+4)==s.charAt(i+5)) s.charAt(i+4) s.charAt s i+4 i 4 s.charAt(i+5) s.charAt s i+5 i 5 {System.out.println("Yes");System.exit(0);} System.out.println("Yes") System.out.println System.out System System.out "Yes" System.exit(0) System.exit System 0 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) {
		Scanner ob=new Scanner(System.in);
		int n=ob.nextInt();
		String s="";
		for (int i=0; i<n; i++) {
			char c1=ob.next().charAt(0);
			s=s+c1;
			char c2=ob.next().charAt(0);
			s=s+c2;
		}
		for(int i=0;i<=s.length()-6;i+=2)
		{
		if((s.charAt(i)==s.charAt(i+1))&&(s.charAt(i+2)==s.charAt(i+3))&&(s.charAt(i+4)==s.charAt(i+5)))
		{System.out.println("Yes");System.exit(0);}
		}
		System.out.println("No");
	}
} public class Main {
	
	public static void main(String[] args) {
		Scanner ob=new Scanner(System.in);
		int n=ob.nextInt();
		String s="";
		for (int i=0; i<n; i++) {
			char c1=ob.next().charAt(0);
			s=s+c1;
			char c2=ob.next().charAt(0);
			s=s+c2;
		}
		for(int i=0;i<=s.length()-6;i+=2)
		{
		if((s.charAt(i)==s.charAt(i+1))&&(s.charAt(i+2)==s.charAt(i+3))&&(s.charAt(i+4)==s.charAt(i+5)))
		{System.out.println("Yes");System.exit(0);}
		}
		System.out.println("No");
	}
} Main
import java.util.Arrays;
import java.util.Scanner;
import java.util.Vector;
 
public class Main {
	
	public static void main(String[] args) {
		Scanner ob=new Scanner(System.in);
		int n=ob.nextInt();
		String s="";
		for (int i=0; i<n; i++) {
			char c1=ob.next().charAt(0);
			s=s+c1;
			char c2=ob.next().charAt(0);
			s=s+c2;
		}
		for(int i=0;i<=s.length()-6;i+=2)
		{
		if((s.charAt(i)==s.charAt(i+1))&&(s.charAt(i+2)==s.charAt(i+3))&&(s.charAt(i+4)==s.charAt(i+5)))
		{System.out.println("Yes");System.exit(0);}
		}
		System.out.println("No");
	}
}