Sunyoung wants to visit Sanggeun. They both live in a hilly region, and Sunyoung strongly dislikes walking up and down hills.
Sunyoung has a contour map of the region where the two of them live. Using this map, she wants to compute, for a walk from her house to Sanggeun's house, the total height she must climb and the total height she must descend, making both sums as small as possible.
The map is drawn on the xy-plane. Sunyoung's house is at (0, 0) and Sanggeun's house is at (100000, 0). Each contour line is given as a polygon. No polygon intersects itself or any other polygon, and neither house lies on any contour line.
The first line contains the number of test cases T (T ≤ 100).
The first line of each test case contains the number of contour lines N (0 ≤ N ≤ 2500). Each of the next N lines describes one contour line. On each such line, the first integer Hi is the height of the contour (1 ≤ Hi ≤ 1000) and the second integer Pi is the number of vertices of the polygon (3 ≤ Pi ≤ 2000). The following integers give the vertices in the order x1, y1, x2, y2, …, xPi, yPi, where every coordinate is an integer with -300000 ≤ xi, yi ≤ 300000.
For each test case, print the total height to climb and the total height to descend, separated by a single space, on one line.