This page is still under construction.

Parts of this page are still being built. What you see may change.

Battleship

Time limit2sMemory limit256 MB

Summary
Decide whether three axis-aligned rectangles (rotatable, non-overlapping) fit inside an A x B rectangle.
Level

Medium7 of 10

Topics
Geometry, Brute force, Greedy, Implementation
Solved
No attempts yet

Problem

Petya and Vasya play battleship with slightly modified rules. Vasya has lost ten games in a row and does not intend to lose again. He analyzed Petya's battle tactics and found a serious flaw in them (or at least he very much hopes so). It turned out that on the field there is an A×BA \times B rectangle of cells that Petya never fired at during all ten games. So Vasya decided to take his three largest ships and place them in this rectangle.

Vasya's plans are far-reaching, of course, but first he has to deal with some minor problems. For example, he needs to find out whether he can place his three ships so that they fit entirely inside the given rectangle. By the rules, ships are rectangles that must be placed parallel to the sides of the field. Ships may be rotated 90 degrees. Ships may touch each other, but they must not share any cell of the field.

Input

The first line contains an integer tt (1≤t≤1051 \le t \le 10^5), the number of tests. Each test consists of 4 lines. The first of them contains two integers AA and BB (1≤A,B≤1091 \le A, B \le 10^9), the dimensions of the rectangle in which the ships must be placed. The next three lines contain two integers each, aia_i and bib_i (1≤ai,bi≤1091 \le a_i, b_i \le 10^9), the dimensions of the ii-th ship.

Output

Print tt lines, the answers to the tests from the input. For each test, print Yes if the ships can be placed and No otherwise.

Examples1

  1. Example 1

    Input
    2
    7 7
    6 3
    6 1
    3 3
    4 4
    5 1
    1 1
    1 2
    
    Expected output
    Yes
    No