#define TASKNAME "weyland"
#include <cstdio>
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <ctime>
#include <cctype>
#include <cstdlib>
#include <cassert>
#include <functional>
#include <iomanip>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <vector>
 
#define EPS (1e-9)
#define INF (int(1e9))
#define INFLONG ((long long)(1e18))
#define sqr(a) ((a) * (a))
#define all(a) (a).begin(), (a).end()
#define zero(a) memset(a, 0, sizeof(a))
#define abs(a) (((a) < 0) ? -(a) : (a))
#define sz(a) (int)a.size()
#define fst first
#define snd second
#define y1 osrughosduvgarligybakrybrogvba
#define y0 aosfigdalrowgyalsouvgrlvygalri                               
#define mp make_pair
#define pb push_back
#define next dlkjdslfkdj
#define prev dsdflksdfjl
#define hash lkdfjldskfj
#define pi 3.1415926535897932384626433832795
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef vector <int> vi;
typedef vector <vi> vvi;
typedef vector <bool> vb;
typedef vector <ll> vll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <int, ll> pil;
typedef vector <pii> vpii;

struct event
{
  int x, type, id;
  event() {x = type = id = 0;}
  event(int x, int type, int id) : x(x), type(type), id(id) {}
};

inline bool operator < (const event &a, const event &b) {return a.x < b.x || (a.x == b.x && a.type > b.type);}

const int maxn = 2e5 + 10;

int n, m, k;
int l[maxn], r[maxn], cost[maxn];

struct less_int
{
  bool operator()(int a, int b)
  {
    return (cost[a] > cost[b]) || (cost[a] == cost[b] && a > b);
  }
};
               
int main()
{
  freopen(TASKNAME".in", "r", stdin);
  freopen(TASKNAME".out", "w", stdout);
  scanf("%d%d%d", &n, &m, &k);
  vector <event> evs;
  for (int i = 0; i < n; i++)
  {
    scanf("%d%d%d", &l[i], &r[i], &cost[i]);
    evs.pb(event(l[i], 1, i));
    evs.pb(event(r[i] + 1, -1, i));
  }                   
  sort(all(evs));

  ll ans = 0, ans_coins = 0;
  set <int, less_int> working, not_working;
  ll sum_cost = 0;
  int last = 0;
  for (int i = 0; i < sz(evs); i++)
  {
    ans += (ll)sz(working) * (evs[i].x - last);
    ans_coins +=  sum_cost * (evs[i].x - last);
    last = evs[i].x;
    //eprintf("%d %d %d %d\n", sz(working), last, evs[i].x, sum_cost);
    //eprintf("+ %d\n", sz(working) * (evs[i].x - last));
    int id = evs[i].id;
    if (evs[i].type == 1)
    {
      if (sz(working) < m)
        working.insert(id), sum_cost += cost[id];
      else
      {
        assert(sz(working) == m);
        int mcidx = *working.begin();
        if (cost[mcidx] > cost[id])
        {
          working.erase(mcidx);
          sum_cost -= cost[mcidx];
          not_working.insert(mcidx);
          working.insert(id);
          sum_cost += cost[id];
        }
        else
          not_working.insert(id);
      }
    }
    else
    {
      //eprintf("%d %d\n", id + 1, working.find(id) == working.end());
      if (working.find(id) != working.end())
      {
        working.erase(id);
        sum_cost -= cost[id];
        if (sz(not_working))
        {
          set <int>::iterator it = not_working.end();
          --it;
          working.insert(*it);
          sum_cost += cost[*it];
          not_working.erase(it);
        }
      }
      else
        not_working.erase(id);
    }
    /*eprintf("Working: \n");
    for (set <int>::iterator it = working.begin(); it != working.end(); it++)
      eprintf("%d %d %d\n", (*it) + 1, l[*it], r[*it]);
    eprintf("\n");*/
  }

  printf("%I64d %I64d\n", ans, ans_coins);
  return 0;
}

