CF1971C.Clock and Strings

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

Clock and Strings

There is a clock labeled with the numbers 11 through 1212 in clockwise order, as shown below.

In this example, (a,b,c,d)=(2,9,10,6)(a,b,c,d)=(2,9,10,6), and the strings intersect.

Alice and Bob have four distinct integers aa, bb, cc, dd not more than 1212. Alice ties a red string connecting aa and bb, and Bob ties a blue string connecting cc and dd. Do the strings intersect? (The strings are straight line segments.)

Input

The first line contains a single integer tt (1t59401 \leq t \leq 5940) — the number of test cases.

The only line of each test case contains four distinct integers aa, bb, cc, dd (1a,b,c,d121 \leq a, b, c, d \leq 12).

Output

For each test case, output "YES" (without quotes) if the strings intersect, and "NO" (without quotes) otherwise.

You can output "YES" and "NO" in any case (for example, strings "yEs", "yes", and "Yes" will be recognized as a positive response).

Note

The first test case is pictured in the statement.

In the second test case, the strings do not intersect, as shown below.

Samples

15
2 9 10 6
3 8 9 1
1 2 3 4
5 3 4 12
1 8 2 10
3 12 11 8
9 10 12 1
12 1 10 2
3 12 6 9
1 9 8 4
6 7 9 12
7 12 9 6
10 12 11 1
3 9 6 12
1 4 3 5
YES
NO
NO
YES
YES
NO
NO
NO
NO
NO
NO
YES
YES
YES
YES

在线编程 IDE

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