Consider a set of polygons whose sides are all parallel to the coordinate axes. Such a set is called a system of contour lines if all of its polygons can be ordered so that the first polygon contains the second one in its interior, the second polygon contains the third one in its interior, and so on. In other words, the polygons can be arranged as a strictly nested chain in which each polygon lies entirely inside the previous one.
Given several sets of axis-parallel polygons, decide for each set whether it is a system of contour lines.
Write a program that:
The first line contains one integer t (1≤t≤10), the number of sets to process. The t sets follow.
The first line of each set contains one integer n (1≤n≤250), the number of polygons in the set. Each of the next n lines describes one polygon. Such a line begins with one integer mi (4≤mi≤250), the number of vertices of the i-th polygon, followed by mi pairs of integers xij and yij (0≤xij,yij≤200000) that give the coordinates of the consecutive vertices of the polygon, separated by single spaces.
Every polygon has sides parallel to the coordinate axes, no two adjacent sides are collinear, and the boundary of each polygon does not cross itself.
Print t lines. The k-th line must contain the word TAK (meaning yes) if the k-th set of polygons is a system of contour lines, and NIE (meaning no) otherwise.
