n = gets.to_i
a, b = n.times.map{gets.split.map(&:to_i)}.transpose
cnt = 0
flg = false
n.times do |i|
  if a[i] == b[i]
    cnt += 1
    if cnt == 3
      flg = true
    end
  else
    cnt = 0
  end
end
if flg
  puts "Yes"
else
  puts "No"
end