import java.util.Scanner;
public class Main{
	static private Scanner scanner;
	static{
		scanner = new Scanner(System.in);
	}
	static public void main(String[] args){
		m2();
	}
	static public void m1(){
		String s = scanner.next();
	  	String result;
		if(s.endsWith("s")){
			result = s + "es";
		}else{
			result = s + "s";
		}
		System.out.println(result);

	}
	static public void m2(){
		int n = scanner.nextInt();
		boolean result = false;
		boolean[] ba = new boolean[]{false,false,false};
		String s;
		String[] sa;
		int d1;
		int d2;
		for(int i = 0; i < n; i++){
			//s = scanner.next();
			//sa = s.split(" ");
			d1 = scanner.nextInt();//Integer.parseInt(sa[0]);
			d2 = scanner.nextInt();//Integer.parseInt(sa[1]);
			if( d1 == d2 ){
				if( ba[0] == false ){
					ba[0] = true;
				}else{
					if( ba[1] == false ){
						ba[1] = true;
					}else{
						if( ba[2] == false ){
							ba[2] = true;
							result = true;
						}else{
						}
					}
				}
				
			}else{
				ba = new boolean[]{false,false,false};
			}

		}
		if(result == true){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}

	}
} import java.util.Scanner; Scanner java.util public class Main{
	static private Scanner scanner;
	static{
		scanner = new Scanner(System.in);
	}
	static public void main(String[] args){
		m2();
	}
	static public void m1(){
		String s = scanner.next();
	  	String result;
		if(s.endsWith("s")){
			result = s + "es";
		}else{
			result = s + "s";
		}
		System.out.println(result);

	}
	static public void m2(){
		int n = scanner.nextInt();
		boolean result = false;
		boolean[] ba = new boolean[]{false,false,false};
		String s;
		String[] sa;
		int d1;
		int d2;
		for(int i = 0; i < n; i++){
			//s = scanner.next();
			//sa = s.split(" ");
			d1 = scanner.nextInt();//Integer.parseInt(sa[0]);
			d2 = scanner.nextInt();//Integer.parseInt(sa[1]);
			if( d1 == d2 ){
				if( ba[0] == false ){
					ba[0] = true;
				}else{
					if( ba[1] == false ){
						ba[1] = true;
					}else{
						if( ba[2] == false ){
							ba[2] = true;
							result = true;
						}else{
						}
					}
				}
				
			}else{
				ba = new boolean[]{false,false,false};
			}

		}
		if(result == true){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}

	}
} Main static private Scanner scanner; scanner static public void main(String[] args){
		m2();
	} main {
		m2();
	} m2() m2 String[] args args static public void m1(){
		String s = scanner.next();
	  	String result;
		if(s.endsWith("s")){
			result = s + "es";
		}else{
			result = s + "s";
		}
		System.out.println(result);

	} m1 {
		String s = scanner.next();
	  	String result;
		if(s.endsWith("s")){
			result = s + "es";
		}else{
			result = s + "s";
		}
		System.out.println(result);

	} String s = scanner.next(); s scanner.next() scanner.next scanner String result; result if(s.endsWith("s")){
			result = s + "es";
		}else{
			result = s + "s";
		} s.endsWith("s") s.endsWith s "s" {
			result = s + "es";
		} result = s + "es" result s + "es" s "es" {
			result = s + "s";
		} result = s + "s" result s + "s" s "s" System.out.println(result) System.out.println System.out System System.out result static public void m2(){
		int n = scanner.nextInt();
		boolean result = false;
		boolean[] ba = new boolean[]{false,false,false};
		String s;
		String[] sa;
		int d1;
		int d2;
		for(int i = 0; i < n; i++){
			//s = scanner.next();
			//sa = s.split(" ");
			d1 = scanner.nextInt();//Integer.parseInt(sa[0]);
			d2 = scanner.nextInt();//Integer.parseInt(sa[1]);
			if( d1 == d2 ){
				if( ba[0] == false ){
					ba[0] = true;
				}else{
					if( ba[1] == false ){
						ba[1] = true;
					}else{
						if( ba[2] == false ){
							ba[2] = true;
							result = true;
						}else{
						}
					}
				}
				
			}else{
				ba = new boolean[]{false,false,false};
			}

		}
		if(result == true){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}

	} m2 {
		int n = scanner.nextInt();
		boolean result = false;
		boolean[] ba = new boolean[]{false,false,false};
		String s;
		String[] sa;
		int d1;
		int d2;
		for(int i = 0; i < n; i++){
			//s = scanner.next();
			//sa = s.split(" ");
			d1 = scanner.nextInt();//Integer.parseInt(sa[0]);
			d2 = scanner.nextInt();//Integer.parseInt(sa[1]);
			if( d1 == d2 ){
				if( ba[0] == false ){
					ba[0] = true;
				}else{
					if( ba[1] == false ){
						ba[1] = true;
					}else{
						if( ba[2] == false ){
							ba[2] = true;
							result = true;
						}else{
						}
					}
				}
				
			}else{
				ba = new boolean[]{false,false,false};
			}

		}
		if(result == true){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}

	} int n = scanner.nextInt(); n scanner.nextInt() scanner.nextInt scanner boolean result = false; result false boolean[] ba = new boolean[]{false,false,false}; ba new boolean[]{false,false,false} String s; s String[] sa; sa int d1; d1 int d2; d2 for(int i = 0; i < n; i++){
			//s = scanner.next();
			//sa = s.split(" ");
			d1 = scanner.nextInt();//Integer.parseInt(sa[0]);
			d2 = scanner.nextInt();//Integer.parseInt(sa[1]);
			if( d1 == d2 ){
				if( ba[0] == false ){
					ba[0] = true;
				}else{
					if( ba[1] == false ){
						ba[1] = true;
					}else{
						if( ba[2] == false ){
							ba[2] = true;
							result = true;
						}else{
						}
					}
				}
				
			}else{
				ba = new boolean[]{false,false,false};
			}

		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			//s = scanner.next();
			//sa = s.split(" ");
			d1 = scanner.nextInt();//Integer.parseInt(sa[0]);
			d2 = scanner.nextInt();//Integer.parseInt(sa[1]);
			if( d1 == d2 ){
				if( ba[0] == false ){
					ba[0] = true;
				}else{
					if( ba[1] == false ){
						ba[1] = true;
					}else{
						if( ba[2] == false ){
							ba[2] = true;
							result = true;
						}else{
						}
					}
				}
				
			}else{
				ba = new boolean[]{false,false,false};
			}

		} {
			//s = scanner.next();
			//sa = s.split(" ");
			d1 = scanner.nextInt();//Integer.parseInt(sa[0]);
			d2 = scanner.nextInt();//Integer.parseInt(sa[1]);
			if( d1 == d2 ){
				if( ba[0] == false ){
					ba[0] = true;
				}else{
					if( ba[1] == false ){
						ba[1] = true;
					}else{
						if( ba[2] == false ){
							ba[2] = true;
							result = true;
						}else{
						}
					}
				}
				
			}else{
				ba = new boolean[]{false,false,false};
			}

		} d1 = scanner.nextInt() d1 scanner.nextInt() scanner.nextInt scanner d2 = scanner.nextInt() d2 scanner.nextInt() scanner.nextInt scanner if( d1 == d2 ){
				if( ba[0] == false ){
					ba[0] = true;
				}else{
					if( ba[1] == false ){
						ba[1] = true;
					}else{
						if( ba[2] == false ){
							ba[2] = true;
							result = true;
						}else{
						}
					}
				}
				
			}else{
				ba = new boolean[]{false,false,false};
			} d1 == d2 d1 d2 {
				if( ba[0] == false ){
					ba[0] = true;
				}else{
					if( ba[1] == false ){
						ba[1] = true;
					}else{
						if( ba[2] == false ){
							ba[2] = true;
							result = true;
						}else{
						}
					}
				}
				
			} if( ba[0] == false ){
					ba[0] = true;
				}else{
					if( ba[1] == false ){
						ba[1] = true;
					}else{
						if( ba[2] == false ){
							ba[2] = true;
							result = true;
						}else{
						}
					}
				} ba[0] == false ba[0] ba 0 false {
					ba[0] = true;
				} ba[0] = true ba[0] ba 0 true {
					if( ba[1] == false ){
						ba[1] = true;
					}else{
						if( ba[2] == false ){
							ba[2] = true;
							result = true;
						}else{
						}
					}
				} if( ba[1] == false ){
						ba[1] = true;
					}else{
						if( ba[2] == false ){
							ba[2] = true;
							result = true;
						}else{
						}
					} ba[1] == false ba[1] ba 1 false {
						ba[1] = true;
					} ba[1] = true ba[1] ba 1 true {
						if( ba[2] == false ){
							ba[2] = true;
							result = true;
						}else{
						}
					} if( ba[2] == false ){
							ba[2] = true;
							result = true;
						}else{
						} ba[2] == false ba[2] ba 2 false {
							ba[2] = true;
							result = true;
						} ba[2] = true ba[2] ba 2 true result = true result true {
						} {
				ba = new boolean[]{false,false,false};
			} ba = new boolean[]{false,false,false} ba new boolean[]{false,false,false} if(result == true){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		} result == true result true {
			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" public class Main{
	static private Scanner scanner;
	static{
		scanner = new Scanner(System.in);
	}
	static public void main(String[] args){
		m2();
	}
	static public void m1(){
		String s = scanner.next();
	  	String result;
		if(s.endsWith("s")){
			result = s + "es";
		}else{
			result = s + "s";
		}
		System.out.println(result);

	}
	static public void m2(){
		int n = scanner.nextInt();
		boolean result = false;
		boolean[] ba = new boolean[]{false,false,false};
		String s;
		String[] sa;
		int d1;
		int d2;
		for(int i = 0; i < n; i++){
			//s = scanner.next();
			//sa = s.split(" ");
			d1 = scanner.nextInt();//Integer.parseInt(sa[0]);
			d2 = scanner.nextInt();//Integer.parseInt(sa[1]);
			if( d1 == d2 ){
				if( ba[0] == false ){
					ba[0] = true;
				}else{
					if( ba[1] == false ){
						ba[1] = true;
					}else{
						if( ba[2] == false ){
							ba[2] = true;
							result = true;
						}else{
						}
					}
				}
				
			}else{
				ba = new boolean[]{false,false,false};
			}

		}
		if(result == true){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}

	}
} public class Main{
	static private Scanner scanner;
	static{
		scanner = new Scanner(System.in);
	}
	static public void main(String[] args){
		m2();
	}
	static public void m1(){
		String s = scanner.next();
	  	String result;
		if(s.endsWith("s")){
			result = s + "es";
		}else{
			result = s + "s";
		}
		System.out.println(result);

	}
	static public void m2(){
		int n = scanner.nextInt();
		boolean result = false;
		boolean[] ba = new boolean[]{false,false,false};
		String s;
		String[] sa;
		int d1;
		int d2;
		for(int i = 0; i < n; i++){
			//s = scanner.next();
			//sa = s.split(" ");
			d1 = scanner.nextInt();//Integer.parseInt(sa[0]);
			d2 = scanner.nextInt();//Integer.parseInt(sa[1]);
			if( d1 == d2 ){
				if( ba[0] == false ){
					ba[0] = true;
				}else{
					if( ba[1] == false ){
						ba[1] = true;
					}else{
						if( ba[2] == false ){
							ba[2] = true;
							result = true;
						}else{
						}
					}
				}
				
			}else{
				ba = new boolean[]{false,false,false};
			}

		}
		if(result == true){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}

	}
} Main
import java.util.Scanner;
public class Main{
	static private Scanner scanner;
	static{
		scanner = new Scanner(System.in);
	}
	static public void main(String[] args){
		m2();
	}
	static public void m1(){
		String s = scanner.next();
	  	String result;
		if(s.endsWith("s")){
			result = s + "es";
		}else{
			result = s + "s";
		}
		System.out.println(result);

	}
	static public void m2(){
		int n = scanner.nextInt();
		boolean result = false;
		boolean[] ba = new boolean[]{false,false,false};
		String s;
		String[] sa;
		int d1;
		int d2;
		for(int i = 0; i < n; i++){
			//s = scanner.next();
			//sa = s.split(" ");
			d1 = scanner.nextInt();//Integer.parseInt(sa[0]);
			d2 = scanner.nextInt();//Integer.parseInt(sa[1]);
			if( d1 == d2 ){
				if( ba[0] == false ){
					ba[0] = true;
				}else{
					if( ba[1] == false ){
						ba[1] = true;
					}else{
						if( ba[2] == false ){
							ba[2] = true;
							result = true;
						}else{
						}
					}
				}
				
			}else{
				ba = new boolean[]{false,false,false};
			}

		}
		if(result == true){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}

	}
}
