P29859 [洛谷] [COCI2009-2010#6] GREMLINI
提高
题目描述

Problem Description

There are $n$ types of gremlins, numbered as $1, \dots, n$.

$t$ years ago, an accident created $n$ gremlins (considered as newly born, not mature), each of a different type.

The $i$-th type of gremlin takes $y_i$ years to mature after birth. Once mature, it immediately lays $k_i$ eggs (gremlins are asexual) and then dies. The eggs are numbered $1, \dots, k_i$. The $j$-th egg takes $h_{i,j}$ years to hatch, and the hatched gremlin is of type $g_{i,j}$.

Determine the maximum generation of gremlins that exist now, excluding those that have not yet hatched. Assume the ancestors are of the 1st generation, their offspring are of the 2nd generation, their grandchildren are of the 3rd generation, and so on.

Input Format

The first line contains $n$ and $t$.

The next $3n$ lines are grouped in sets of three.

Each group's first line contains $k_i$ and $y_i$.
Each group's second line contains $g_{i,1}, \ldots, g_{i,k_i}$.
Each group's third line contains $h_{i,1}, \ldots, h_{i,k_i}$.

Output Format

A single line with an integer representing the maximum generation of gremlins that exist now.

Sample Input and Output

Input Sample #1

1 42
1 10
1
5

Output Sample #1

2

Input Sample #2

2 42
1 10
1
5
1 5
1
5

Output Sample #2

3

Input Sample #3

3 8
4 5
1 2 3 2
1 2 1 3
1 1
3
1
2 1
1 2
2 1

Output Sample #3

4

Notes

[Sample #2 Explanation]

10 years after the accident, the original gremlin (1st generation) lays an egg and dies. 15 years after the accident, the egg hatches into a new gremlin (2nd generation). 25 years after the accident, the 2nd generation gremlin lays an egg and dies. 30 years after the accident, the egg hatches into a new gremlin (3rd generation). 40 years after the accident, the 3rd generation gremlin lays an egg and dies. 42 years after the accident, this egg has not yet hatched and is therefore not counted.

[Data Range]

$1 \le n \le 100, 1 \le t \le 10^{15}, 1 \le k_i, y_i, h_{i,j} \le 1000, 1 \le g_{i,j} \le n$.

This problem is scored according to the original COCI settings, with a maximum score of $130$.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
1 42 1 10 1 5
样例输出
2