Experiment "X": Explosions Expected

No attempts yetTime limit1sMemory limit512 MB

Problem

Vasya has taken the post of court alchemist, and his task is to brew the philosopher's stone by mixing ingredients.

There are KK ingredients. An experiment is a plan (a1,a2,,aK)(a_1, a_2, \dots, a_K): Vasya takes aia_i ounces of the ii-th ingredient, pours everything into the crucible, and heats it. Every aia_i is a non-negative integer, and the total amount may not exceed the crucible capacity SS, so a1+a2++aKSa_1 + a_2 + \dots + a_K \le S. In every experiment at least two ingredients are actually used: at least two of the aia_i are strictly positive.

So far every mixture has exploded. Vasya has spotted a monotonicity rule: if a plan (a1,,aK)(a_1, \dots, a_K) explodes, then every plan (b1,,bK)(b_1, \dots, b_K) with biaib_i \ge a_i for all ii explodes as well.

Vasya has already carried out MM experiments, and all of them exploded. Call a plan definitely unsuccessful when the monotonicity rule guarantees it will explode, i.e. when at least one of the MM exploded plans (c1,,cK)(c_1, \dots, c_K) satisfies aicia_i \ge c_i for every ii.

Count how many valid experiment plans are not definitely unsuccessful. A plan is valid when every aia_i is a non-negative integer, a1++aKSa_1 + \dots + a_K \le S, and at least two of the aia_i are positive.

Input

The first line contains three integers KK, SS, and MM (2K302 \le K \le 30, 2S100002 \le S \le 10000, 0M200 \le M \le 20), where MM is the number of experiments already conducted. Each of the next MM lines contains KK integers describing one already-conducted experiment (all of which exploded).

Output

Print one integer: the number of valid experiment plans that are not definitely unsuccessful. This count can be very large, so print the exact value.