Jim Beam
Difficulty: Hard

Jim likes to play with laser beams.  
Jim stays at point $(0,0)$.  
There is a mirror at point $(X_m, Y_m)$ and a wall between points $(X_1, Y_1)$ and $(X_2, Y_2)$.

Jim wants to find out if he can point the laser beam on the mirror.

**Input Format**  
First line contains the number of test cases, $T$.  
Each subsequent line contains one test case: space separated integers that denote endpoints of the wall $X_1, Y_1$, $X_2, Y_2$ and position of the mirror $X_m, Y_m$.  

**Output Format**  
The answer for each test case: Display `YES` if Jim can point the laser beam to the mirror, otherwise display `NO` .  

**Constraints**  
$1 \le T \le 100$  
$0 \le |X_1|,|Y_1|,|X_2|,|Y_2|,|X_m|,|Y_m| \le 10^6$  
Mirror doesn't have common points with wall.  
Wall doesn't pass through the point $(0,0)$.  

**Sample Input**

	5
	1 2 2 1 2 2
	-1 1 1 1 1 -1
	1 1 2 2 3 3
	2 2 3 3 1 1
    0 1 1 1 0 2

**Sample Output**
	
    NO
	YES
	NO
	YES
    NO
    
    

Input Format:

Output Format:

Sample Input:

Sample Output:

Python 3 starter code:
#
# Complete the 'solve' function below.
#
# The function is expected to return a STRING.
# The function accepts following parameters:
#  1. INTEGER x1
#  2. INTEGER y1
#  3. INTEGER x2
#  4. INTEGER y2
#  5. INTEGER xm
#  6. INTEGER ym
#

def solve(x1, y1, x2, y2, xm, ym):
    # Write your code here




Reference solution (C++):
###C++  
```cpp  
#include <iostream>
using namespace std;    
    
long long cross_product(long long ax, long long ay, 
                        long long bx, long long by, 
                        long long cx, long long cy)
{
    return (bx - ax) * (cy - ay) - (by - ay) * (cx - ax);
}
    
bool inside(long long ax, long long ay, 
            long long bx, long long by, 
            long long cx, long long cy)
{
    return (min(ax,bx)<=cx && cx<=max(ax,bx) && 
            min(ay,by)<=cy && cy<=max(ay,by));
}
    
bool intersect (long long ax, long long ay, 
                long long bx, long long by, 
                long long cx, long long cy, 
                long long dx, long long dy) 
{
    long long abc=cross_product(ax, ay, bx, by, cx, cy);
    long long abd=cross_product(ax, ay, bx, by, dx, dy);
    long long cda=cross_product(cx, cy, dx, dy, ax, ay);
    long long cdb=cross_product(cx, cy, dx, dy, bx, by);
    
    if (((abc>0 && abd<0)||(abc<0 && abd>0)) &&
        ((cda>0 && cdb<0)||(cda<0 && cdb>0)))
        return true;
        
    if (abc == 0 && inside(ax, ay, bx, by, cx, cy))return true;
    if (abd == 0 && inside(ax, ay, bx, by, dx, dy))return true;
    if (cda == 0 && inside(cx, cy, dx, dy, ax, ay))return true;
    if (cdb == 0 && inside(cx, cy, dx, dy, bx, by))return true;
    
    return false;
}
    
void solve()
{
    long long x, y, ax, ay, bx, by;
    cin >> ax >> ay >> bx >> by >> x >> y;
    cout << (intersect(0, 0, x, y, ax, ay, bx, by)?"NO\n":"YES\n");
}
    
int main()
{
    int t;
    cin >> t;
    for (;t;--t)
    {
        solve();
    }
    return 0;
} 
```