CF2120A.Square of Rectangles

传统题 时间 2000 ms 内存 256 MiB 3 尝试 1 已通过 1 标签

Square of Rectangles

Aryan is an ardent lover of squares but a hater of rectangles (Yes, he knows all squares are rectangles). But Harshith likes to mess with Aryan. Harshith gives Aryan three rectangles of sizes l1×b1l_1\times b_1, l2×b2l_2\times b_2, and l3×b3l_3\times b_3 such that l3l2l1l_3\leq l_2\leq l_1 and b3b2b1b_3\leq b_2\leq b_1. Aryan, in order to defeat Harshith, decides to arrange these three rectangles to form a square such that no two rectangles overlap and the rectangles are aligned along edges. Rotating rectangles is not allowed. Help Aryan determine if he can defeat Harshith.

Input

Each test contains multiple test cases. The first line contains the number of test cases tt (1t1001 \le t \le 100). The description of the test cases follows.

Each test case contains a single line with 66 space-separated integers l1,b1,l2,b2,l3l_1, b_1, l_2, b_2, l_3, and b3b_3 (1l3l2l11001 \leq l_3\le l_2\le l_1\le 100, 1b3b2b11001\le b_3\le b_2\le b_1 \leq 100) — the dimensions of the three rectangles.

Output

For each testcase, print "YES" if the rectangles can be arranged to form a square; otherwise, "NO".

You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.

Note

In the second test case, the three rectangles 5×35\times 3, 5×15\times 1, and 5×15\times 1 can be arranged as follows to form a square.

In the fourth test case, it can be proven that the rectangles can't be arranged to form a square with the given constraints.

Samples

5
100 100 10 10 1 1
5 3 5 1 5 1
2 3 1 2 1 1
8 5 3 5 3 3
3 3 3 3 2 1
NO
YES
YES
NO
NO

在线编程 IDE

建议全屏模式获得最佳体验