Gremlins

Time limit1sMemory limit128 MB

Problem

Gremlins are small, cute, fuzzy imaginary creatures. There are N kinds of gremlins, numbered 1 through N.

Exactly T years ago, an explosion at a research lab created one gremlin of each of the N kinds. The gremlins created at that moment appear already hatched.

A gremlin hatches from an egg, goes through a growth period, and then becomes fully grown. A gremlin of kind i spends Yi years in its growth period after hatching, and the moment it finishes growing it lays Ki eggs and then dies. The kind of gremlin that hatches from each egg may differ, and the time each egg takes to hatch may also differ.

Now, T years after the explosion, the scientists want to know which gremlin among all gremlins that have ever existed has the most ancestors. Here an ancestor means a direct forebear only — the parent, the parent's parent, and so on up the line. Gremlins that have not yet hatched are not counted, and every egg that hatches during the current year (year T) is considered hatched.

Write a program that finds the number of ancestors of the gremlin with the most ancestors.

Input

The first line contains the number of gremlin kinds N and the number of years T that have passed since the explosion. (1 ≤ N ≤ 100, 1 ≤ T ≤ 10^15)

The information for each kind then follows, three lines per kind, given in order from kind 1 to kind N (3N lines in total):

  • Line 1: two natural numbers Ki and Yi. (1 ≤ Ki ≤ 1000, 1 ≤ Yi ≤ 1000) Ki is the number of eggs this kind lays, and Yi is the length of its growth period after hatching.
  • Line 2: Ki natural numbers. The j-th value is the kind of gremlin that hatches from the j-th egg.
  • Line 3: Ki natural numbers. The j-th value is the number of years the j-th egg takes to hatch, which is between 1 and 1000 inclusive.

Output

Print the number of ancestors of the gremlin that has the most ancestors.