For an axis-aligned rectangle and a line segment, count how many points lie on both the rectangle boundary and the segment. Print 4 when the segment overlaps the boundary and there are infinitely many intersection points.
The first line contains T. Each test case gives a rectangle by (xmin,ymin) and (xmax,ymax), then a segment from (x1,y1) to (x2,y2).
For each test case, print the finite intersection count, or 4 when the intersections are infinite.