// Arup Guha
// 4/5/2015
// Solution to 2015 April USACO Silver Problem: Bessie's Birthday Buffet
// Written in contest, commented later.

import java.util.*;
import java.io.*;

public class buffet {

	public static int n;
	public static int cost;
	public static int[] energy;
	public static int[][] g;

	public static void main(String[] args) throws Exception {

		BufferedReader stdin = new BufferedReader(new FileReader("buffet.in"));
		StringTokenizer tok = new StringTokenizer(stdin.readLine());
		n = Integer.parseInt(tok.nextToken());
		cost = Integer.parseInt(tok.nextToken());

		energy = new int[n];
		g = new int[n][];

		// Read in graph info here.
		for (int i=0; i<n; i++) {
			tok = new StringTokenizer(stdin.readLine());
			energy[i] = Integer.parseInt(tok.nextToken());
			int deg = Integer.parseInt(tok.nextToken());
			g[i] = new int[deg];
			for (int j=0; j<deg; j++)
				g[i][j] = Integer.parseInt(tok.nextToken())-1;
		}

		// Run a BFS for each patch of grass.
		int[][] dist = new int[n][];
		for (int i=0; i<n; i++)
			dist[i] = bfs(i);

		// Sort by value.
		pair[] energyPair = new pair[n];
		for (int i=0; i<n; i++)
			energyPair[i] = new pair(energy[i], i);
		Arrays.sort(energyPair);

		int[] dp = new int[n];
		dp[0] = energyPair[0].value;
		int res = dp[0];

		// Outer DP loop.
		for (int i=1; i<n; i++) {

			// j is where we are building off of.
			dp[i] = energyPair[i].value;
			for (int j=0; j<i; j++) {
				if (dist[energyPair[j].index][energyPair[i].index] == -1) continue;
				if (dp[j]-dist[energyPair[j].index][energyPair[i].index] < 0) continue;
				dp[i] = Math.max(dp[i], dp[j]-dist[energyPair[j].index][energyPair[i].index]+energyPair[i].value);
			}
			res = Math.max(res, dp[i]);
		}

		// Solve and write out the result.
		FileWriter fout = new FileWriter(new File("buffet.out"));
		fout.write(res+"\n");
		fout.close();
	}

	// A typical BFS from v, returns all distances from v to the other vertices.
	public static int[] bfs(int v) {

		int[] dist = new int[n];
		Arrays.fill(dist, -1);
		dist[v] = 0;

		LinkedList<Integer> q = new LinkedList<Integer>();
		q.offer(v);

		while (q.size() > 0) {

			int cur = q.poll();
			int curD = dist[cur];

			for (int i=0; i<g[cur].length; i++) {
				int next = g[cur][i];
				if (dist[next] == -1) {
					q.offer(next);
					dist[next] = curD+cost;
				}
			}
		}

		return dist;
	}
}

class pair implements Comparable<pair> {

	public int value;
	public int index;


	public pair(int cost, int where) {
		value = cost;
		index = where;
	}

	public int compareTo(pair other) {
		return this.value - other.value;
	}

	public String toString() {
		return index+": "+value;

	}
}
