**Problem Description**

And the roads between the two cities are varied. Each road has a different length.

Lili don't want to go any road more than once, and she also want to make the shortest journey.

Data ensure that there are at least two roads between adjacent cities.

Please output the shortest total travel length.

**Input**

The first line contains a T which means the number of data sets.

In each data set:

The first line contains one integers n — the number of cities in Lily’s plan.

The next i th line firstly contains one integer ki which is the number of road between i th city and i+1 th city ,and then ki distinct integers a1, a2, ..., aki — the distance of the road ai.

Limit:

T <= 100

n ,ki <= 1000

1 <= ai <= 10000

**Output**

For each data set, output answer in one line.

**Sample Input**

1 5 2 1 5 2 10 15 3 4 6 7 7 98 45 12 32 45 21 54

**Sample Output**

74

**Source**

2018绍兴市联赛