import java.io.*;
import java.util.*;

public class weyland_pk {

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;

	public String nextToken() throws IOException {
		while ((st == null) || (!st.hasMoreTokens()))
			st = new StringTokenizer(br.readLine());
		return st.nextToken();
	}

	public int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	public double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	public long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	class Worker {
		int l, r, cost, id;

		public Worker(int l, int r, int cost, int id) {
			super();
			this.l = l;
			this.r = r;
			this.cost = cost;
			this.id = id;
		}
	}

	class CompareByCost implements Comparator<Worker> {

		@Override
		public int compare(Worker o1, Worker o2) {
			if (o1.cost != o2.cost)
				return Integer.compare(o1.cost, o2.cost);
			else
				return Integer.compare(o1.id, o2.id);
		}

	}

	class Event implements Comparable<Event> {
		int x, type;
		Worker w;

		@Override
		public int compareTo(Event o) {
			return Integer.compare(x, o.x);
		}

		public Event(int x, int type, Worker w) {
			super();
			this.x = x;
			this.type = type;
			this.w = w;
		}

	}

	public void solve() throws IOException {
		int n = nextInt();
		int m = nextInt();
		int k = nextInt();
		Worker[] w = new Worker[n];
		ArrayList<Event> e = new ArrayList<weyland_pk.Event>();
		for (int i = 0; i < n; i++) {
			w[i] = new Worker(nextInt(), nextInt(), nextInt(), i);
			e.add(new Event(w[i].l, 1, w[i]));
			e.add(new Event(w[i].r + 1, -1, w[i]));
		}
		TreeSet<Worker> works = new TreeSet<weyland_pk.Worker>(
				new CompareByCost());
		TreeSet<Worker> rests = new TreeSet<weyland_pk.Worker>(
				new CompareByCost());
		long curCost = 0;
		int last = 0;
		long sumCount = 0;
		long sumCost = 0;
		Collections.sort(e);
		for (Event ev : e) {
			sumCount = sumCount + (long)works.size() * (ev.x - last);
			sumCost = sumCost + curCost * (long)(ev.x - last) ;
			last = ev.x;
			if (ev.type == 1) {
				if (works.size() == m && works.last().cost > ev.w.cost) {
					rests.add(works.last());
					curCost = curCost - works.last().cost;
					works.remove(works.last());
				}
				if (works.size() < m) {
					works.add(ev.w);
					curCost = curCost + ev.w.cost;
				} else {
					rests.add(ev.w);
				}
			} else {
				if (rests.contains(ev.w)) {
					rests.remove(ev.w);
				} else {
					works.remove(ev.w);
					curCost = curCost - ev.w.cost;
				}
				while (works.size() < m && rests.size() > 0) {
					works.add(rests.first());
					curCost = curCost + rests.first().cost;
					rests.remove(rests.first());
				}
			}
		}
		out.println(sumCount + " " + sumCost);

	}

	public void run() {
		try {
			br = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);

			br = new BufferedReader(new FileReader("weyland.in"));
			out = new PrintWriter("weyland.out");

			solve();

			out.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public static void main(String[] args) {
		new weyland_pk().run();
	}
}