import sys n=int(input()) for i in range(n): a,b,c,d=map(int,input().split()) print("SELECT count(*) FROM point WHERE %d<=x AND x<=%d AND %d<=y AND y<=%d;" % (a,b,c,d)) sys.stdout.flush