Jas has built several towers of different heights out of blocks. Each block has an integer written on it. A tower is more valuable the larger the sum of the blocks it contains. Jas wants to build the most valuable tower possible, but he does not want to completely destroy the towers he has already built. So he decided that the only move he may make is to choose two towers of different heights and:
This produces two towers of the same heights as before, but possibly with a different arrangement of the numbers on the individual blocks (see the figure).

Figure: An example of Jas's move for the towers (4,5,7,1) and (3,6).
Find the maximum value of a tower that Jas can build.
The first line contains an integer n (1≤n≤500000), the number of towers Jas built. Each of the next n lines describes one tower. The (i+1)-th line contains an integer wi (1≤wi≤1000000), the height of the i-th tower, followed by wi integers x1,x2,…,xwi (−1000000≤xk≤1000000), where xk is the number written on the k-th block from the top of the i-th tower. The total number of blocks K across all towers does not exceed 1000000.
Output a single integer: the maximum value of a tower that Jas can build.

Explanation: From towers no. 2 and no. 3 Jas can build the tower (4,6), and then from that tower together with tower no. 1 he can build the tower (4,6,7,1), whose value is 18.