Read problems statements in Mandarin Chinese  and Russian. 
Chef has N simple polygons (non self intersecting polygons) in which no two of them intersect with each other. For any two polygons P_{1}, P_{2}, either P_{1} lies inside P_{2} or vice versa. 
Chef wants you to count number of polygons lying strictly inside each of the polygons.

------ Input ------ 

First line of the input contains an integer T denoting the number of test cases. First line of each test case contains a single integer N denoting the number of polygons.
The description of N polygons is as follows:

The first line contains an integer M_{i} denoting the number of vertices in the i^{th} polygon
The second line contains M_{i} pairs of integers X_{i, j}, Y_{i, j} representing coordinates of vertices of i^{th}  polygon in clockwise or counterclockwise order

------ Output ------ 

For each test case, output a single line containing N space-separated integers such that i^{th} of them represents number of polygons lying inside the i^{th} polygon.

------ Constraints ------ 

$1 ≤ T ≤ 10^{5}$
$2 ≤ N ≤ 10^{5}$
$3 ≤ M_{i} ≤ 10^{5}$
$The sum of M_{i} (or total amount of given points) over all test cases in one test file does not exceed 2*10^{5}$
$Absolute value of each coordinate doesn't exceed 10^{9}$

Subtask 1: (10 points)

$T ≤ 6$
$2 ≤ N ≤ 10$
$3 ≤ M_{i} ≤ 10$
$Absolute value of each coordinate doesn't exceed 30$

Subtask 2: (20 points)

$All polygons are  convex polygons .$

Subtask 3: (70 points)

$Original constraints$

----- Sample Input 1 ------ 
1
3
6
-2 2 -1 1 2 2 2 -1 1 -2 -2 -2
3
-1 -1 1 -1 1 1
4
3 3 -3 3 -3 -3 3 -3
----- Sample Output 1 ------ 
1 0 2
----- explanation 1 ------ 

In the picture the first polygon is marked in green, second - in red and third in blue color.

Difficulty: MEDIUM_HARD

Solutions:
def coords_to_x_only(list_coordinates):
	x_list = list_coordinates[::2]
	return x_list

def find_rank_max_x(list_max, index):
	rank = 0
	for element in list_max:
		if element[1] == index:
			return rank
		else:
			rank += 1
cases = int(input())
for case in range(cases):
	nb_polygons = int(input())
	max_x_list = list()
	for polygon in range(nb_polygons):
		nb_vertices = int(input())
		coordinates = list(map(int, input().strip().split()))
		x_vertices = coords_to_x_only(coordinates)
		max_x_list.append((max(x_vertices), polygon))
	max_x_list_sorted = sorted(max_x_list)[::-1]
	nb_polygons_inside = [0] * nb_polygons
	for (max_x, index) in max_x_list_sorted:
		nb_polygons -= 1
		nb_polygons_inside[index] = str(nb_polygons)
	print(' '.join(nb_polygons_inside))


for _ in range(int(input())):
	n = int(input())
	arr = []
	ans = [0] * n
	for i in range(n):
		m = int(input())
		po = [int(i) for i in input().split()][::2]
		arr.append([i, max(po)])
	arr.sort(key=lambda x: x[1])
	for x in range(n):
		ans[arr[x][0]] = x
	print(*ans)


t = int(input())
for it in range(t):
	n = int(input())
	x_pno_array = []
	for i in range(n):
		m = int(input())
		max_x_coord = max([int(word) for word in input().split()][::2])
		x_pno_array.append((max_x_coord, i))
	x_pno_array = sorted(x_pno_array)
	pno_rank_array = []
	for i in range(n):
		pno_rank_array.append((x_pno_array[i][1], i))
	pno_rank_array = sorted(pno_rank_array)
	print(*[elem[1] for elem in pno_rank_array])


t = int(input())
while t > 0:
	n = int(input())
	b = list(range(n))
	c = list(range(n))
	q = 0
	for i in range(0, n):
		m = int(input())
		a = list(map(int, input().split()))
		y = a[0]
		j = 2
		while j < len(a):
			temp = a[j]
			if y < temp:
				y = temp
			j = j + 2
		b[i] = y
		c[i] = b[i]
	c.sort()
	d = list(range(n))
	for i in range(0, n):
		first = 0
		last = len(c) - 1
		found = False
		while first <= last and (not found):
			midpoint = (first + last) // 2
			if c[midpoint] == b[i]:
				found = True
			elif b[i] < c[midpoint]:
				last = midpoint - 1
			else:
				first = midpoint + 1
		d[i] = midpoint
	print(' '.join(map(str, d)))
	t = t - 1


t = int(input())
for x in range(t):
	n = int(input())
	a = []
	for y in range(n):
		nod = int(input())
		lst = input().split()
		maxi = int(lst[0])
		k = 0
		while k < 2 * nod:
			maxi = max(maxi, int(lst[k]))
			k += 2
		a.append((maxi, y))
	b = sorted(a)
	c = []
	for z in range(n):
		c.append(0)
	h = 0
	for w in b:
		c[w[1]] = h
		h += 1
	s = ''
	for m in c:
		s = s + str(m) + ' '
	print(s)


for _ in range(int(input())):
	n = int(input())
	xs = []
	for i in range(n):
		m = int(input())
		xy = list(map(int, input().split()))
		x = xy[::2]
		xs.append((max(x), i))
	s = sorted(xs, reverse=True)
	answer = [None for i in range(n)]
	for i in range(len(s)):
		answer[s[i][1]] = str(n - 1 - i)
	print(' '.join(answer))


from operator import itemgetter
t = int(input())
for i in range(t):
	n = int(input())
	xseq = []
	for j in range(n):
		v = int(input())
		vert = list(map(int, input().split()))
		xseq.append([max(vert[::2]), j + 1, 0])
	xseq.sort(key=itemgetter(0))
	for j in range(n):
		xseq[j][2] = j
	xseq.sort(key=itemgetter(1))
	for j in range(n - 1):
		print(xseq[j][2], end=' ')
	print(xseq[n - 1][2])


for t in range(int(input())):
	n = int(input())
	a = []
	ans = []
	for p in range(n):
		ans.append(0)
		m = int(input())
		temp = list(map(int, input().split()))
		maxx = temp[0]
		i = 2
		while i < 2 * m:
			if temp[i] > maxx:
				maxx = temp[i]
			i += 2
		a.append([maxx, p])
	a.sort()
	for i in range(n):
		index = a[i][1]
		ans[index] = i
	for i in ans:
		print(i, end=' ')
	print()