#C5939. Rectangle Overlap Checker

    ID: 49643 Type: Default 1000ms 256MiB

Rectangle Overlap Checker

Rectangle Overlap Checker

You are given the coordinates of two rectangles. Each rectangle is represented by the coordinates of its bottom-left and top-right corners. Your task is to determine whether the two rectangles overlap.

Formally, let the first rectangle be determined by the points \( (x_1, y_1) \) and \( (x_2, y_2) \), and the second rectangle by the points \( (x_3, y_3) \) and \( (x_4, y_4) \). The two rectangles do not overlap if
\(x_1 \ge x_4\) or \(x_3 \ge x_2\) or \(y_1 \ge y_4\) or \(y_3 \ge y_2\).

Otherwise, they overlap.

Note: Two rectangles sharing a common edge are considered as not overlapping.

inputFormat

The input is read from standard input (stdin). The first line contains an integer (T) representing the number of test cases. Each of the following (T) lines contains eight space-separated integers: (x_1), (y_1), (x_2), (y_2), (x_3), (y_3), (x_4), (y_4), where ((x_1, y_1)) and ((x_2, y_2)) are the bottom-left and top-right corners of the first rectangle, and ((x_3, y_3)) and ((x_4, y_4)) are the bottom-left and top-right corners of the second rectangle.

outputFormat

For each test case, output a single line to standard output (stdout) containing 1 if the rectangles overlap, and 0 otherwise.## sample

1
0 0 2 2 1 1 3 3
1