#K78332. Right Triangle Formation

    ID: 35063 Type: Default 1000ms 256MiB

Right Triangle Formation

Right Triangle Formation

You are given several sets of magical points, each belonging to a different city. Determine if it is possible to form a right-angled triangle with the right angle fixed at the origin \( (0,0) \). More specifically, for each city, you need to check if there exist two distinct points \(B\) and \(C\) from the given set such that one lies on the x-axis and the other lies on the y-axis. Formally, if one point is \(B=(x,0)\) (with \(x\) possibly nonzero) and another point is \(C=(0,y)\) (with \(y\) possibly nonzero), then the triangle \(OBC\) (where \(O=(0,0)\)) is a right-angled triangle with the right angle at \(O\).

If such a pair exists among the points of a city, output YES for that city; otherwise, output NO.

Note: A point at the origin (\(0,0\)) qualifies as lying on both axes, but it cannot be used twice. In other words, if the only candidate for both axes is the same single point \( (0,0) \), then it is not sufficient.

inputFormat

The input is read from standard input (stdin) and has the following format:

T
N1
x11 y11
x12 y12
... 
x1N1 y1N1
N2
x21 y21
x22 y22
... 
...
NT
xT1 yT1
xT2 yT2
... 
xTNT yTNT

Here, \(T\) is the number of cities (test cases). For each city, the first line is an integer \(N\) representing the number of points in that city. The following \(N\) lines each contain two integers representing the coordinates \(x\) and \(y\) of a magical point.

outputFormat

For each city, output a single line to standard output (stdout) containing either YES or NO. The output should have exactly \(T\) lines, where the i-th line is the answer for the i-th city.

## sample
4
3
0 0
1 2
3 0
3
0 0
6 8
3 0
3
1 1
2 2
3 3
4
0 0
1 2
4 0
0 3
YES

YES NO YES

</p>