# Enter your code here. Read input from STDIN. Print output to STDOUT def lies(point, x0, x1, y0, y1) (point[0] == x0 || point[0] == x1) || (point[1] == y0 || point[1] == y1) end q = gets.to_i for i in 1..q do t = gets.to_i points = [] for j in 1..t do x, y = gets.split(' ').map(&:to_i) points << [x, y] end pp = points.sort {|p1, p2| (p1[0] <=> p2[0])} x0 = pp.first[0] x1 = pp.last[0] pp = points.sort {|p1, p2| (p1[1] <=> p2[1])} y0 = pp.first[1] y1 = pp.last[1] # p "#{x0} #{x1} #{y0} #{y1}" fall = true pp.each do |point| if !lies(point, x0, x1, y0, y1) fall = false end end printf("%s\n", fall ? "YES" : "NO") end