Balls and Holes

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

문제

Bobo invents a game and keeps playing.

A game (a_1,a_2,,a_m,b_1,b_2,,b_l)(\\{a\_1, a\_2, \dots, a\_m\\}, \\{b\_1, b\_2, \dots, b\_l\\}) is played on the axis. First, bobo places mm balls at a_1,a_2,,a_ma\_1, a\_2, \dots, a\_m, respectively. Then bobo digs ll holes at b_1+0.5,b_2+0.5,,b_l+0.5b\_1 + 0.5, b\_2 + 0.5, \dots, 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 nn sets S_1,S_2,,S_nS\_1, S\_2, \dots, S\_n, and he wants to know how many games as (S_i,S_j)(S\_i, S\_j) (i<j)(i < j) he can win.

입력

The first line contains an integer nn (2n50002 \leq n \leq 5000).

Each of the following nn lines contains an integer k_ik\_i, which denotes the size of S_iS\_i, followed by k_ik\_i distinct integers S_i,1,S_i,2,,S_i,k_iS\_{i, 1}, S\_{i, 2}, \dots, S\_{i, k\_i} which denotes the set S_iS\_i (1k_i50,1S_i,j501 \leq k\_i \leq 50, 1 \leq S\_{i, j} \leq 50).

출력

A single integer denotes the number games bobo can win.