function spilitInput(input) {
  var splited = [];
  var rows = input.split('\n');
  for (var i = 0; i < rows.length; i += 1) {
    splited.push(rows[i].split(' '));
  }
  return splited;
}
function Main(input) {
  var splited = spilitInput(input);
  var r_count = 0;
  for (var i = 1; i < splited.length && r_count < 3; i += 1) {
    if (splited[i][0] == splited[i][1]) {
      r_count += 1;
      if (r_count >= 3) break;
    } else {
      r_count = 0;
    }
  }
  if (r_count >= 3) {
    console.log('Yes');
  } else {
    console.log('No');
  }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));