#980
Unrated
GREMLINI
시간 제한
1s
메모리 제한
32MB
제출
0
정답
0
맞힌 사람
0
정답 비율
0.0%

문제

Gremlins are small, funny, fuzzy creatures. In times long gone they used to cause quite a ruckus, but now most of them live decent, honest family lives. There are N different types of gremlins, coded with numbers 1 to N for your convenience. Legend has it that T years ago a laboratory accident occurred causing N gremlins, one of each type to be born. As you all know, in order for gremlins to reproduce, no mating rituals are required. Just add a dash of watter and you instantly get a few new cocoons. Gremlins of type i need exactly Yi years to mature and spawn Ki cocoons. For each cocoon you know how much years does it take to hatch, and which gremlin type is contained within. The original gremlin unfortunately dies while producing cocoons. Now, T years after the original accident. Scientist wonder what is the longest ancestral chain whose genome is currently represented. They are only interested in ancestors of hatched gremlins, not those still cocooned. You are safe to assume that all gremlins that were supposed to hatch this year did so.

입력

The first line of input contains two integers N and T (1 ≤N ≤100, 1 ≤T ≤1015), number of gremlin types and number of years after the original accident. Next 3∙N lines contain gremlin type descriptions, three lines per type:

  • First line contains integers Ki and Yi (1 ≤Ki ≤1000, 1 ≤Yi ≤1000),

number of cocoons formed when this gremlin type spawns and number of years this gremlin type needs to reach maturity.

  • The second line contains Ki integers between 1 and N inclusive, types

of gremlins hatched from cocoons formed by this gremlin type.

  • The third line contains Ki integers between 1 and 1000, representing

hatching time for each cocoon, in years.

출력

The first and only line of output should contain the length of the currently longest ancestral chain.

예제 입력 1

1 42
1 10
1
5

예제 출력 1

2

예제 입력 2

2 42
1 10
1
5
1 5
1
5

예제 출력 2

3

예제 입력 3

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

예제 출력 3

4
코드 제출

코드를 제출하려면 로그인이 필요합니다.

로그인
내 제출
제출 내역이 없습니다.
맞은 사람
아직 맞은 사람이 없습니다.
난이도 투표
Unrated0명 투표
로그인 후 AC 받으면 투표할 수 있습니다.
전체 제출
제출 내역이 없습니다.