# frozen_string_literal: true

Q = gets.to_i
X = Q.times.map { gets.chomp.split.map(&:to_i) }

X.each do |a, b, c, d|
  puts <<~SQL
    SELECT count(*) FROM point WHERE x >= #{a} AND x <= #{b} AND y >= #{c} AND y <= #{d};
  SQL
  STDOUT.flush
end