gets.to_i.times do x1,x2,y1,y2 = gets.split.map(&:to_i) if x1 == x2 && y1 == y2 puts "SELECT count(*) FROM point WHERE #{x1}=x AND #{y1}=y;" elsif x1 == x2 puts "SELECT count(*) FROM point WHERE #{x1}=x AND #{y1}<=y AND y<=#{y2};" elsif y1 == y2 puts "SELECT count(*) FROM point WHERE #{x1}<=x AND x<=#{x2} AND #{y1}=y;" else puts "SELECT count(*) FROM point WHERE #{x1}<=x AND x<=#{x2} AND #{y1}<=y AND y<=#{y2};" end STDOUT.flush end