P17383 [PacNW 2025] Fractal Painting

Description

A fractal painting consists of infinitely many line segments. The first segment, called A, connects $(0,0)$ to $(x_0,y_0)$. Segments B and C connect $(x_0,y_0)$ to $(x_1,y_1)$ and $(x_2,y_2)$, respectively. The rest of the painting is defined recursively. From $(x_1,y_1)$, draw segments D and E so that the three-segment figure B-D-E is similar to A-B-C. Here, similar means that one figure can be matched point-for-point to the other by translation, rotation, and scaling. Likewise, draw segments F and G from $(x_2,y_2)$ so that C-F-G is similar to A-B-C. Continue this process forever. Determine whether some rectangle of finite size can contain the entire fractal painting.

Input Format

The first line contains an integer $T$ ($1\le T\le10^4$), the number of test cases. Each test case contains six integers $x_0,y_0,x_1,y_1,x_2,y_2$. Every coordinate is between $-10^4$ and $10^4$, inclusive. The points $(0,0)$, $(x_0,y_0)$, $(x_1,y_1)$, and $(x_2,y_2)$ are all distinct.

Output Format

For each test case, output `YES` if the entire painting fits inside some rectangle of finite size. Otherwise, output `NO`.