Bessie's Birthday Buffet

No attempts yetTime limit1sMemory limit256 MB

Problem

For Bessie the cow's birthday, Farmer John picked the best field on his farm and let her graze there as she likes.

The field holds NN patches of grass (1N10001 \le N \le 1000), numbered 11 through NN. The quality values of the patches are all different. When Bessie eats grass of quality QQ, she gains QQ units of energy. Each patch is joined to at most 1010 neighboring patches by bidirectional paths, and every move between two adjacent patches costs Bessie EE units of energy (1E10000001 \le E \le 1\,000\,000). Bessie may start grazing at any patch she likes, and she stops at the moment her accumulated energy is largest.

Bessie is a picky cow. Once she eats grass of some quality, she never again eats grass of that quality or lower. Walking through a patch without eating it is fine. Passing a high quality patch on purpose and coming back for it later can pay off.

Compute the maximum amount of energy Bessie can accumulate.

Input

The first line contains NN and EE, separated by a space.

Each of the next NN lines describes one patch, in order from patch 11 to patch NN. A line starts with the quality QQ of the patch (1Q10000001 \le Q \le 1\,000\,000) and the number of neighbors DD (0D100 \le D \le 10), followed by the DD neighbor numbers. Paths are bidirectional, so every path appears on the lines of both of its patches.

Output

Print the maximum amount of energy Bessie can accumulate on one line.

Note

In the first example Bessie starts at patch 4 and eats the grass there for 55 units of energy. She then moves to patch 5, spending 22 units of energy. The grass at patch 5 has lower quality, so she leaves it and spends another 22 units of energy moving to patch 3. Finally she eats the grass at patch 3 for 66 units of energy, so her total is 77.