for _ in range(int(input())): print("SELECT count(*) FROM point WHERE x>={0} AND x<={1} AND y>={2} AND y<={3};".format(input().split()))