Bobo invents a game and keeps playing.
A game (a_1,a_2,…,a_m,b_1,b_2,…,b_l) is played on the axis. First, bobo places m balls at a_1,a_2,…,a_m, respectively. Then bobo digs l holes at b_1+0.5,b_2+0.5,…,b_l+0.5. Finally bobo pushes all balls forward so that the balls fall into the holes. bobo wins if and only if there are odd number of holes containing at least one ball.
Now bobo has n sets S_1,S_2,…,S_n, and he wants to know how many games as (S_i,S_j) (i<j) he can win.
The first line contains an integer n (2≤n≤5000).
Each of the following n lines contains an integer k_i, which denotes the size of S_i, followed by k_i distinct integers S_i,1,S_i,2,…,S_i,k_i which denotes the set S_i (1≤k_i≤50,1≤S_i,j≤50).
A single integer denotes the number games bobo can win.