fun main(){
    val n = readLine()!!.split(" ")[0].toInt()
    var count = 0
    var flag = 0
    for (i in 0 until n){
        val d = readLine()!!.split(" ").map { it.toInt() }
        if (count >= 3){
            println("Yes")
            flag = 1
            break
        }
        if (d[0] == d[1]){
            count++
            if (count >= 3){
                println("Yes")
                flag = 1
                break
            }
        } else {
            if (count >= 3){
                println("Yes")
                flag = 1
                break
            } else {
                count = 0
            }
        }
    }
    if (flag != 1) println("No")

}
