# Enter your code here. Read input from STDIN. Print output to STDOUT q = gets.to_i m = [] q.times do |i| m[i] = [] n = gets.to_i n.times do |j| m[i][j] = gets.split(" ").map(&:to_i) end end m.each do |set| xs = [] ys = [] set.each do |point| x = point[0] y = point[1] if !xs.include? x xs << x end if !ys.include? y ys << y end end xs.length != 2 || ys.length != 2 ? puts("NO") : puts("YES") end