lines = []
while line = gets
    lines << line.chomp.split(' ').map(&:to_i)
end
n = lines.shift
nn = n[0] - 2
i = 0

nn.times {
  if lines[i].uniq.one? && lines[i + 1].uniq.one? && lines[i + 2].uniq.one?
  	puts "Yes"
    exit
  end
  i += 1
}

puts "No"