Clique Festival

아직 제출이 없습니다시간 제한2초메모리 제한512 MB

문제

John has a graph with nn vertices labeled with integers 1,,n1, \ldots, n. Initially, there are no edges in the graph. Then John modifies the graph kk times, each time adding a clique to the graph. He chooses an integer aa and a set SS which is a non-empty subset of the set of integers 1,2,,n1, 2, \ldots, n. For each unordered pair (i,j)(i, j) such that i,jSi, j \in S and iji \neq j, John adds an undirected edge between the vertices ii and jj with weight aa. It is possible that parallel edges appear in John's graph.

The distance between vertices uu and vv is defined as follows. Denote d_u,vd\_{u,v} as the minimum weight of the edge between vertices uu and vv, or \infty if there is no such edge. Then dist(u,v)=min_i_1,,i_p(d_u,i_1+d_i_1,i_2++d_i_p1,i_p+d_i_p,v)\mathrm{dist}(u,v) = \min\limits\_{i\_1, \ldots, i\_p} \left(d\_{u,i\_1} + d\_{i\_1,i\_2} + \ldots + d\_{i\_{p-1},i\_p} + d\_{i\_p,v}\right). In other words, the distance is the length of the shortest path between uu and vv.

Your task is to calculate _i=1n1_j=i+1ndist(i,j)\sum\limits\_{i=1}^{n-1} \sum\limits\_{j = i+1}^n dist(i,j). It is guaranteed that all summands are finite.

입력

The first line contains two integers nn and kk (1n100,0001 \le n \le 100\\,000, 1k181 \le k \le 18). The next kk lines contain the descriptions of the added cliques. Each of these lines contains integers aa (1a1071 \le a \le 10^7), S|S| (1Sn1 \le |S| \le n), and then S|S| integers s_1,,s_Ss\_1, \ldots, s\_{|S|} (1s_in1 \le s\_i \le n, all s_is\_i are distinct). These are the weight of edges in the clique, the number of vertices in the clique, and the labels of these vertices, respectively.

The sum of all S|S| in the input does not exceed 300,000300\\,000.

출력

Output a single integer: the answer to the problem.