Each test case gives three points A, B and C. Decide on which side of the directed line from A to B the point C lies: LEFT if C is strictly to the left of someone walking from A towards B, RIGHT if strictly to the right, and ON if the three points are collinear.
The first line has n. Each of the next n lines has six integers x1 y1 x2 y2 x3 y3, meaning A = (x1, y1), B = (x2, y2) and C = (x3, y3). A and B are always distinct.
Print one line per test case: LEFT, RIGHT or ON.
1 <= n <= 100000 |x|, |y| <= 10^9 The cross product used to decide can reach 8 x 10^18, so use 64-bit or arbitrary-precision integers.
1000 ms256 MB
3 0 0 4 0 2 1 0 0 4 0 2 0 0 0 4 0 2 -1
LEFT ON RIGHT
Walking from (0,0) to (4,0) faces east, so the upper side (y > 0) is on the left. (2,1) is left, (2,0) lies on the line, and (2,-1) is right.
1 5 5 9 5 5 9
LEFT
From (5,5) to (9,5) you face east, and (5,9) is north of you, which is on the left.