# Enter your code here. Read input from STDIN. Print output to STDOUT queries = gets.strip.to_i queries.times do num_points = gets.strip.to_i points_array= [] num_points.times do point = gets.split(' ') points_array.push(point) end x_values = [] y_values = [] points_array.each do |point| x_values.push(point[0]) y_values.push(point[1]) end if x_values.uniq.count > 2 || y_values.uniq.count > 2 print "NO" else print "YES" end end