N = gets.to_i
a, b = N.times.map{gets.split.map(&:to_i)}.transpose


kaisuu = 0
for i in 0..N-3
    if a[i] == b[i] && a[i+1] == b[i+1] && a[i+2] == b[i+2] then
        puts 'Yes'
        exit
    end
end
puts "No"