q = int(input())

for _ in range(q):
    a, b, c, d = map(int, input().split())
    ans = "SELECT count(*) FROM point WHERE {0} <= x AND x <= {1} AND {2} <= y AND y <= {3};".format(a, b, c, d)
    print(ans)