Molecular biologists study the genomes (that is, the sequences of genes) of organisms in order to draw conclusions about the evolution of species and the workings of cells and tissues. They compare the structure and function of genes and identify genes that are very similar to one another, called homologous genes.
While examining viruses that attack bacteria (called bacteriophages, or simply phages), they noticed a striking phenomenon. If the gene sequences of several phages are written one below another and homologous genes are painted with the same color, a peculiar mosaic appears:

To describe this phenomenon they defined a measure called the coefficient of mosaicism. It is defined for one phage only in comparison with the others, and it equals the total number of points awarded as follows. Consider the i-th phage. For every two of its genes A and B, and for every two distinct phages j and k (with j=i and k=i) such that:
the i-th phage receives 1 point. Each quadruple (A,B,j,k) is counted exactly once: the quadruples (A,B,j,k) and (B,A,k,j) describe the same situation.
For example, in the mosaic above phage 3 has coefficient 2: its blue gene has a homolog in phage 1 but not in phage 2, while its orange gene has a homolog in phage 2 but not in phage 1 (and a symmetric pair holds for the brown and orange genes). Phage 1 has coefficient 6: it scores once each for the gene pairs red-blue and red-brown, and twice each for yellow-blue and yellow-brown.
Computing the coefficients by hand is quite hard, so write a program that reads the descriptions of homologous genes across a set of phages and computes the coefficient of mosaicism for every phage.
The first line contains one integer n (3≤n≤300), the number of phages.
Each of the next n lines describes one phage. The i-th such line begins with an integer li (1≤li≤300), the number of genes in phage i, followed by li integers ai1,ai2,…,aili (1≤aij≤100000) that list its genes in order. Consecutive numbers are separated by single spaces.
Two genes are homologous if and only if they are written as the same number. No number appears twice within a single phage (a phage never contains two mutually homologous genes).
Print n lines. The i-th line contains a single integer: the coefficient of mosaicism of the i-th phage.