# Enter your code here. Read input from STDIN. Print output to STDOUT t = gets.strip.to_i t.times do n = gets.strip.to_i xx = [] yy = [] _x = {} _y = {} n.times do x, y = gets.strip.split(" ").map(&:to_i) xx << x yy << y _x[x] ||= [] _y[y] ||= [] _x[x] << y _y[y] << x end minx, maxx = xx.minmax miny, maxy = yy.minmax yes = true xx.zip(yy).each do |x, y| next if x == minx || x == maxx next if y == miny || y == maxy yes = false end if yes puts "YES" else puts "NO" end end