import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		sc.nextLine();
		int count = 0;
		String str = "";
		String[] line;
		List<String[]> lineArray = new ArrayList() ;
		
      	while (sc.hasNextLine()) {
      		str = sc.nextLine();
      		line = str.split(" ");
      		lineArray.add(line);
        }
      	
      	for (String[] comLine : lineArray) {
      		if (comLine[0].equals(comLine[1])) {
      			count++;
      			if (count == 3) {
      				break;
      			}
      		} else {
      			count = 0;
      		}
      	}

      	if (count == 3) {
      		System.out.println("Yes");
      	} else {
      		System.out.println("No");
      	}
	}
} import java.util.ArrayList; ArrayList java.util import java.util.List; List java.util import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		sc.nextLine();
		int count = 0;
		String str = "";
		String[] line;
		List<String[]> lineArray = new ArrayList() ;
		
      	while (sc.hasNextLine()) {
      		str = sc.nextLine();
      		line = str.split(" ");
      		lineArray.add(line);
        }
      	
      	for (String[] comLine : lineArray) {
      		if (comLine[0].equals(comLine[1])) {
      			count++;
      			if (count == 3) {
      				break;
      			}
      		} 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);
		sc.nextLine();
		int count = 0;
		String str = "";
		String[] line;
		List<String[]> lineArray = new ArrayList() ;
		
      	while (sc.hasNextLine()) {
      		str = sc.nextLine();
      		line = str.split(" ");
      		lineArray.add(line);
        }
      	
      	for (String[] comLine : lineArray) {
      		if (comLine[0].equals(comLine[1])) {
      			count++;
      			if (count == 3) {
      				break;
      			}
      		} else {
      			count = 0;
      		}
      	}

      	if (count == 3) {
      		System.out.println("Yes");
      	} else {
      		System.out.println("No");
      	}
	} main {
		Scanner sc = new Scanner(System.in);
		sc.nextLine();
		int count = 0;
		String str = "";
		String[] line;
		List<String[]> lineArray = new ArrayList() ;
		
      	while (sc.hasNextLine()) {
      		str = sc.nextLine();
      		line = str.split(" ");
      		lineArray.add(line);
        }
      	
      	for (String[] comLine : lineArray) {
      		if (comLine[0].equals(comLine[1])) {
      			count++;
      			if (count == 3) {
      				break;
      			}
      		} 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) sc.nextLine() sc.nextLine sc int count = 0; count 0 String str = ""; str "" String[] line; line List<String[]> lineArray = new ArrayList() ; lineArray new ArrayList() while (sc.hasNextLine()) {
      		str = sc.nextLine();
      		line = str.split(" ");
      		lineArray.add(line);
        } sc.hasNextLine() sc.hasNextLine sc {
      		str = sc.nextLine();
      		line = str.split(" ");
      		lineArray.add(line);
        } str = sc.nextLine() str sc.nextLine() sc.nextLine sc line = str.split(" ") line str.split(" ") str.split str " " lineArray.add(line) lineArray.add lineArray line for (String[] comLine : lineArray) {
      		if (comLine[0].equals(comLine[1])) {
      			count++;
      			if (count == 3) {
      				break;
      			}
      		} else {
      			count = 0;
      		}
      	} String[] comLine lineArray {
      		if (comLine[0].equals(comLine[1])) {
      			count++;
      			if (count == 3) {
      				break;
      			}
      		} else {
      			count = 0;
      		}
      	} {
      		if (comLine[0].equals(comLine[1])) {
      			count++;
      			if (count == 3) {
      				break;
      			}
      		} else {
      			count = 0;
      		}
      	} if (comLine[0].equals(comLine[1])) {
      			count++;
      			if (count == 3) {
      				break;
      			}
      		} else {
      			count = 0;
      		} comLine[0].equals(comLine[1]) comLine[0].equals comLine[0] comLine 0 comLine[1] comLine 1 {
      			count++;
      			if (count == 3) {
      				break;
      			}
      		} count++ count if (count == 3) {
      				break;
      			} count == 3 count 3 {
      				break;
      			} break; {
      			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 public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		sc.nextLine();
		int count = 0;
		String str = "";
		String[] line;
		List<String[]> lineArray = new ArrayList() ;
		
      	while (sc.hasNextLine()) {
      		str = sc.nextLine();
      		line = str.split(" ");
      		lineArray.add(line);
        }
      	
      	for (String[] comLine : lineArray) {
      		if (comLine[0].equals(comLine[1])) {
      			count++;
      			if (count == 3) {
      				break;
      			}
      		} else {
      			count = 0;
      		}
      	}

      	if (count == 3) {
      		System.out.println("Yes");
      	} else {
      		System.out.println("No");
      	}
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		sc.nextLine();
		int count = 0;
		String str = "";
		String[] line;
		List<String[]> lineArray = new ArrayList() ;
		
      	while (sc.hasNextLine()) {
      		str = sc.nextLine();
      		line = str.split(" ");
      		lineArray.add(line);
        }
      	
      	for (String[] comLine : lineArray) {
      		if (comLine[0].equals(comLine[1])) {
      			count++;
      			if (count == 3) {
      				break;
      			}
      		} else {
      			count = 0;
      		}
      	}

      	if (count == 3) {
      		System.out.println("Yes");
      	} else {
      		System.out.println("No");
      	}
	}
} Main
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		sc.nextLine();
		int count = 0;
		String str = "";
		String[] line;
		List<String[]> lineArray = new ArrayList() ;
		
      	while (sc.hasNextLine()) {
      		str = sc.nextLine();
      		line = str.split(" ");
      		lineArray.add(line);
        }
      	
      	for (String[] comLine : lineArray) {
      		if (comLine[0].equals(comLine[1])) {
      			count++;
      			if (count == 3) {
      				break;
      			}
      		} else {
      			count = 0;
      		}
      	}

      	if (count == 3) {
      		System.out.println("Yes");
      	} else {
      		System.out.println("No");
      	}
	}
}