function Main(input) {
    input = input.trim().split("\n").map(function(x) { return x.split(" ")});
    let N = parseInt(input[0][0], 10);
    let arr_D = [];
    for (let i = 0; i < N; i++){
        arr_D.push(input[i + 1].map(e => parseInt(e, 10)));
    }
    arr_D.push([0, 1]);
    let tmp = -1;
    let tmp2;
    let ans = 'No';
    for (let i = 0; i < N + 1; i++){
        if (arr_D[i][0] !== arr_D[i][1]){
            tmp2 = i;
            if (tmp2 - tmp > 3){
                ans = 'Yes';
                break;
            } else {
                tmp = tmp2;
            }
        }
    }
    console.log(ans);
    
    
}



Main(require("fs").readFileSync("/dev/stdin", "utf8"));
