// Arup Guha
// 6/27/2012
// Solution to 2008 Southeast Regional Problem: Heart of the Country

import java.util.*;

class vertex {

	public int id;
	public int troops;
	public int[] next;

	public vertex(int num, int numtroops, int[] adj) {
		id = num;
		troops = numtroops;
		next = adj;
		Arrays.sort(next);
	}
}

public class b {

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);

		int N = stdin.nextInt();
		int K = stdin.nextInt();

		while (N != 0) {

			vertex[] graph = new vertex[N];

			// Read in the graph.
			for (int i=0; i<N; i++) {
				int troops = stdin.nextInt();
				int numadj = stdin.nextInt();
				int[] list = new int[numadj];
				for (int j=0; j<numadj; j++)
					list[j] = stdin.nextInt();
				graph[i] = new vertex(i, troops, list);
			}

			solve(graph, K);

			N = stdin.nextInt();
			K = stdin.nextInt();
		}
	}

	public static void solve(vertex[] graph, int K) {

		ArrayList<Integer> weak = findWeak(graph, K);

		// Continually remove weak vertices until there are none to remove.
		while (weak.size() > 0) {
			remove(graph, weak);
			weak = findWeak(graph, K);
		}

		// Then, just count up your answer.
		int cities = 0, troops = 0;
		for (int i=0; i<graph.length; i++) {
			if (graph[i] != null) {
				cities++;
				troops += graph[i].troops;
			}
		}

		System.out.println(cities+" "+troops);
	}


	// Returns a list of the weak vertices in the graph.
	public static ArrayList<Integer> findWeak(vertex[] graph, int K) {

		ArrayList<Integer> ans = new ArrayList<Integer>();

		// Check if vertex i is weak.
		for (int i=0; i<graph.length; i++) {

			// Not in the graph anymore...
			if (graph[i] == null) continue;

			// Add up it and all neighbors.
			int sum = graph[i].troops;
			for (int j=0; j<graph[i].next.length; j++) {
				sum += graph[graph[i].next[j]].troops;
				if (sum >= K)
					break;
			}

			// This node is weak, so add it to our set.
			if (sum < K)
				ans.add(i);
		}

		return ans;
	}

	// Remove vertices in weak from graph.
	public static void remove(vertex[] graph, ArrayList<Integer> weak) {

		// The easy part of the removal.
		for (int i=0; i<weak.size(); i++)
			graph[weak.get(i)] = null;

		// Now, we have to go back and remove these nodes from existing neighbor lists.
		for (int i=0; i<graph.length; i++) {

			if (graph[i] != null) {

				// Sort these so I can remove them efficiently.
				Collections.sort(weak);
				int[] temp = new int[graph[i].next.length];

				int weak_i = 0;
				int temp_i = 0;
				int j = 0;

				// Similar to sorted list matching. Iterate through both sorted lists, skipping items
				// in both lists.
				while (j<graph[i].next.length) {

					if (weak_i == weak.size() || graph[i].next[j] < weak.get(weak_i)) {
						temp[temp_i++] = graph[i].next[j];
						j++;
					}
					else if (graph[i].next[j] == weak.get(weak_i)){
						weak_i++;
						j++;
					}
					else
						weak_i++;
				}

				// Copy the remaining neighbor vertices back to the list.
				graph[i].next = new int[temp_i];
				for (j=0; j<temp_i; j++)
					graph[i].next[j] = temp[j];
			}
		}
	}
}