# Enter your code here. Read input from STDIN. Print output to STDOUT t = gets.chomp.to_i t.times do n = gets.chomp.to_i arr = [] brr = [] n.times do a, b = gets.chomp.split(" ").map &:to_i arr.push(a) brr.push(b) end arr.uniq! brr.uniq! if ((arr.length.to_i != 2) and (brr.length.to_i != 2)) puts "NO" else puts "YES" end end