The Heart of the Country

Time limit1sMemory limit128 MB

Problem

The nation of Graphia is at war. Its neighbors have long watched with envy as Graphia built prosperous cities and linked them with a network of highways, and now they want a piece of it.

Graphia consists of several cities connected by highways. The terrain is rough, so the only way to travel between cities is along the highways. Each city has a number of troops quartered in it. The military command needs at least $K$ troops to defend a city; a city is defended by the troops stationed there together with the troops of every city connected to it by a single highway (with no city in between). Troops any farther away cannot arrive in time. The enemy attacks only one city at a time, so a city's troops may help defend that city and any of its neighbors. If a city cannot be defended, the command must assume its troops are captured and can no longer help defend Graphia.

In the example figure below, with $K = 10$, city C may look well defended, but it will eventually fall.

Graphia's leadership wants to find the Heart of the country: the largest group of cities that can mutually defend one another, even if every other city falls.

More formally, a city is defensible if it can gather a total of at least $K$ troops from itself and from the cities directly adjacent to it. A set of cities is defensible if every city in it is defensible using only troops from itself and from its adjacent cities that are also in the set. The Heart of the country is the largest defensible set of cities: no other defensible set contains more cities.

Input

The input contains several data sets. Each data set begins with two integers $N$ and $K$, where $N$ ($3 \le N \le 1000$) is the number of cities and $K$ is the number of troops required to defend a city. The cities are numbered $0$ through $N-1$.

The next $N$ lines describe the cities, starting with city $0$. Each description begins with an integer $T$ ($0 \le T \le 10000$), the number of troops quartered in that city, followed by an integer $M$, the number of highways leaving that city, and then $M$ integers giving the cities those highways lead to. Within one city's list every city number is distinct, and no highway connects a city to itself. Highways are two-way: if city $i$ appears in city $j$'s list, then city $j$ is guaranteed to appear in city $i$'s list.

The input ends with a line containing two space-separated zeros.

Output

For each data set, print two integers on one line: the number of cities in the Heart of the country and the total number of troops in the Heart of the country. Separate the two integers with a single space. Print no blank lines between data sets.