n = gets.to_i

lines = []
n.times do
  l = gets.split(' ').map(&:to_i)
  lines << l
end

count = 0
lines.map!(&:uniq)
lines.each_with_index do |l,i|
  if l.length == 1
    if count == 2
      puts "Yes"
      break
    elsif count == 1
      count += 1
    elsif count == 0
      count += 1
    end
  else
    count = 0
  end
  if i == (lines.length - 1)
    puts "No" if count < 3
  end
end