Couples

No attempts yetTime limit5sMemory limit128 MB

Problem

The editor-in-chief of the weekly magazine Rhodian Matchmaker wants to devote the next issue to the island's secret couples. The only clue for locating a couple that has not gone public is how often the two people show up together at the parties held on the island.

There are $N$ parties, attended by up to $M$ people. Two people are treated as a potential couple if they attended more than $K$ parties together (that is, at least $K+1$ parties in common). The editor assigns one dedicated journalist to each such potential couple.

Given who attended each party, output how many journalists are needed — that is, the number of pairs of people who attended more than $K$ parties together.

Input

The first line contains three integers $N$, $M$, and $K$ ($1 \le N \le 600000$, $1 \le M \le 20000$, $3 \le K \le 1000$): the number of parties, the number of people, and the co-appearance threshold. Two people count as a potential couple only if they appear together at least $K+1$ times.

Each of the next $N$ lines describes one party: an integer $X$ ($0 \le X < N$), the party's id; an integer $Y$ ($1 \le Y \le M$), the number of attendees; and then $Y$ distinct integers, the ids of the attendees, each in the range $[0, M)$.

Output

Print a single integer: the number of journalists needed, i.e. the number of pairs of people who attended more than $K$ parties together.