Under construction

Still being built. Things may change

Moo University - Emergency Pizza Order

Time limit1sMemory limit1024 MB

Summary
Given each calf's liked toppings out of T, find the maximum number of calves that can each receive a distinct K-topping pizza made only from toppings they like.
Level

Medium7 of 10

Topics
Graph, Combinatorics, Bit manipulation
Solved
No attempts yet

Problem

Moo U's cafeteria has run out of hay, so it must order pizzas for the CC calves (1≤C≤1,0001 \le C \le 1{,}000) attending Moo U. Conveniently, a large pizza from the local pizzeria, Pizza Farm, serves exactly one calf.

Pizza Farm will make one pizza per calf, but because the order is large, it sets three conditions:

  • Pizza Farm has a list of TT vegetarian toppings (1≤T≤301 \le T \le 30). Each pizza must have exactly KK toppings (1≤K≤T1 \le K \le T).
  • No topping can appear twice on one pizza. For example, a pizza cannot have onions and onions.
  • No two pizzas in the order can have the same set of toppings. For example, if pizza 1 has onions, green peppers, pineapples, and wheat grass, then no other pizza can have that exact set. Pizza 2 may still have onions, green peppers, pineapples, and olives.

For ordering purposes, the toppings are numbered 1 to TT.

The calves at Moo U are picky, and some do not like every topping. A calf eats a pizza only if she likes every topping on it. Find the maximum number of calves that can be fed.

Input

The first line contains three integers CC, TT, and KK.

Each of the next CC lines describes the toppings one calf likes. The first integer on the line is the number of toppings that calf likes. The remaining integers are the numbers of those toppings.

Output

Print a single integer: the maximum number of calves that can be fed.

Examples1

  1. Example 1

    Input
    3 2 1
    2 2 1
    1 1
    1 2
    
    Expected output
    2