#### Registered Users Only

Please login to utilize this feature.

Do note that this website only supports submissions in C++.

You are a Pokemon trainer with *P* Pokemon. Each Pokemon has some moves that deal some damage. Specifically, the *i*^{th} Pokemon has *M _{i}* moves, and the

*j*

^{th}of these moves deals

*D*

_{i,j}HP damage (1 ≤

*i*≤

*P*, 1 ≤

*j*≤

*M*). You are fighting an enemy Missingno (a virus Pokemon) with

_{i}*H*HP. This peculiar enemy does not deal damage to your Pokemon for the first

*K*of your moves, and your moves can never miss it too. However, since it's a virus Pokemon, it glitches all your moves such that they can be used only 1 time at most. Furthermore, after

*K*of your Pokemon's moves, if Missingno still has more than 0 HP, it will burst into an outrage and destroy all of your Pokemon.

Naturally, you are interested to know, how many move orderings are there such that Missingno will have 0 or less HP within *K* turns? The first Pokemon you send out will be the (*i* = 1)st Pokemon, and you are allowed to switch Pokemon at any point in time.

## Input

On the first line are integers*H*(1 ≤

*H*≤ 1,000,000,000),

*P*(1 ≤

*P*≤ 6) and

*K*(1 ≤

*K*≤

*M*

_{1}+

*M*

_{2}+...+

*M*). This is followed by

_{P}*P*lines. The

*i*

^{th}of these lines represents the moveset for the

*i*

^{th}Pokemon. The first integer in the

*i*

^{th}line will be the integer

*M*(1 ≤

_{i}*M*≤ 4), then

_{i}*M*integers separated by spaces, the

_{i}*j*

^{th}of these integers being the integer

*D*

_{i,j}(0 ≤

*D*

_{i,j}≤ 60,000,000).

## Output

On the first and only line, output the number of move orderings modulo 13,371,337.## Sample Input 1

4 2 2 2 4 0 3 1 0 2

## Sample Output 1

9

## Explanation for Sample Output 1

We shall assume that the first Pokemon is Charmander with moves Ember and Growl that deal 4 and 0 damage respectively; while the second Pokemon is Rattata with moves Tackle, Tail Whip and Quick Attack that do 1, 0, and 2 damage respectively. The possible move orderings will then be:- Ember
- Ember, Growl
- Ember, (switch to Rattata), Tackle
- Ember, (switch to Rattata), Tail Whip
- Ember, (switch to Rattata), Quick Attack
- Growl, Ember
- (switch to Rattata), Tackle, (switch to Charmander), Ember
- (switch to Rattata), Tail Whip, (switch to Charmander), Ember
- (switch to Rattata), Quick Attack, (switch to Charmander), Ember

*K*moves yet.

### Tags

### Subtasks and Limits

Subtask | Score | #TC | Time | Memory | Scoring |
---|---|---|---|---|---|

1 | 100 | 20 | 1s | 32MB | Average |

2 | 0 | 1 | 1s | 32MB | Average |

### Judge Compile Command

g++-7 ans.cpp -o pokebattle -Wall -static -O2 -lm -m64 -s -w -std=gnu++17 -fmax-errors=512