def detect(x) nand(nand(nand(x[0], x[1]), x[2]), nand(nand(x[3], x[4]), x[5])) end # 0 = true # 1 = false def nand(a, b) if a == 0 and b == 0 1 else 0 end end a = gets.split.map(&:to_i) u = a.uniq as = [0,1].repeated_permutation(u.size).to_a result = 1 as.size.times.each do |i| if detect(a.map { |e| as[i][u.index(e)] }) == 0 result = 0 break end end as.size.times.each do |i| if detect(a.map { |e| as[i][u.index(e)] }) == 0 result = 0 break end end if result == 0 puts 'YES' else puts 'NO' end