LINESEG - Intersection

no tags 

 

Being a student of engineering, you got a craze for Geometry problems. You just started solving some simple geometry problems, and you wondered how about finding whether two given lines intersect, and in what manner. You will be given two line segments on the plane. Each one of them is either vertical or horizontal, ie parallel to X axis or Y axis. You have to determine whether the two segments intersect or not, and if they do, does the segments' intersection forms a point or a line segment?

 

Being a student of engineering, you got a craze for Geometry problems. You just started solving some simple geometry problems, and you wondered how about finding whether two given lines intersect, and in what manner. You will be given two line segments on the plane. Each one of them is either vertical or horizontal, ie parallel to X axis or Y axis. You have to determine whether the two segments intersect or not, and if they do, does the segments' intersection forms a point or a line segment?

 

 

Input

The first line consists of the number T <= 100 - the number of test cases. Each test case consists of 2 lines, each line consisting of 4 integers x1,y1,x2,y2. (x1,y1) and (x2,y2) are the end points of respective line segments. All co-ordinates will lie between -1000 and 1000 inclusive.

Output

For each test case, if the two segments do not intersect at all, print "NO", and if they do, if they intersect at a point, print "POINT", otherwise if their intersection forms a segment, print "SEGMENT".

Example

Input:
3
0 0 0 10
0 0 0 0
0 0 0 1
1 0 1 1
0 0 2 0 1 0 10 0 Output: POINT NO SEGMENT

hide comments
flyingduchman_: 2017-03-12 19:00:43

can be moved to classical

Last edit: 2017-03-12 19:51:38
c_n: 2016-06-05 00:18:48

no tags, Wow.


Added by:Mahesh Chandra Sharma
Date:2011-01-10
Time limit:3s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:Based on a topcoder problem