Castle

No attempts yetTime limit1sMemory limit128 MB

Problem

A satellite sent us a photo of a ruin in the middle of a desert. The ruin turns out to be an ancient castle of a forgotten kingdom, roughly 2000 years old. From the photo we can tell that the floor plan of the castle has the shape of a rectilinear polygon.

A rectilinear polygon is a polygon whose edges are all either horizontal or vertical. Equivalently, at every vertex the interior angle between the two incident edges is either 9090^\circ or 270270^\circ, as shown in Figure 1. A rectilinear polygon is simple when (1) every vertex is incident to exactly two edges and (2) no two edges intersect except at shared end vertices.

Figure 1. (a) A simple rectilinear polygon. (b), (c) Non-simple rectilinear polygons: (b) a vertex has four incident edges; (c) a pair of edges cross each other.

Time has not been kind to the castle. Only its poles remain, that is, the vertices of the simple rectilinear polygon. We must work out how the poles were connected in order to recover the castle's original shape. Figure 2 shows an example.

Formally, you are given a set of nn distinct points in the plane with integer coordinates. Decide whether these points can be the vertices of a simple rectilinear polygon, formed by joining all of them with horizontal and vertical segments that alternate around the boundary. Output YES if a simple rectilinear polygon on all nn points can be reconstructed, and NO otherwise.

Figure 2. (a) The input points. (b) A simple rectilinear polygon reconstructed from them.

Input

The input is read from standard input. The first line contains the number of test cases TT. Each test case begins with a line containing an integer nn, the number of points, where 4n10,0004 \le n \le 10{,}000. Each of the next nn lines contains two integers, the xx- and yy-coordinates of one point, each between 106-10^6 and 10610^6 inclusive. All points within a test case are distinct.

Output

Write the answer to standard output. Print exactly one line per test case: YES if the points form a simple rectilinear polygon, or NO otherwise.