아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Landlord

시간 제한1초메모리 제한256 MB

요약
축에 나란한 두 직사각형 울타리가 평면을 나누는 연결 성분의 개수를 유한 성분과 무한 성분 모두 세어 구한다.
난이도

보통10점 중 5점

유형
기하, 구현
정답자
아직 제출이 없습니다

문제

Calabash is the servant of a landlord. The landlord owns a piece of land, which can be regarded as an infinite 2D plane.

One day the landlord set up two orthogonal rectangular-shaped fences on his land. He asked Calabash a simple problem: how many nonempty connected components is my land divided into by these two fences, both finite and infinite? Calabash couldn't answer this simple question. Please help him! 

Recall that a connected component is a maximal set of points not occupied by the fences, and every two points in the set are reachable without crossing the fence.

입력

The first line of input consists of a single integer TT (1≤T≤10000)(1 \leq T \leq 10000), the number of test cases. 

Each test case contains two lines, specifying the two rectangles. Each line contains four integers x_1,y_1,x_2,y_2x\_1, y\_1, x\_2, y\_2 (0≤x_1,y_1,x_2,y_2≤109,x_1<x_2,y_1<y_2)(0 \leq x\_1, y\_1, x\_2, y\_2 \leq 10^9, x\_1 < x\_2, y\_1 < y\_2), where (x_1,y_1),(x_2,y_2)(x\_1, y\_1), (x\_2, y\_2) are the Cartesian coordinates of two opposite vertices of the rectangular fence. The edges of the rectangles are parallel to the coordinate axes. The edges of the two rectangles may intersect, overlap, or even coincide.

출력

For each test case, print the answer as an integer in one line.

예제1

  1. 예제 1

    입력
    3
    0 0 1 1
    2 2 3 4
    1 0 3 2
    0 1 2 3
    0 0 1 1
    0 0 1 1
    
    예상 출력
    3
    4
    2