#include <bits/stdc++.h>
#define fi first
#define se second
#define all(v) v.begin() , v.end()
#define sz(v) int(v.size())
#define unq(v) sort(all(v)); v.resize(unique(all(v)) - v.begin());
using namespace std;
typedef long long ll;
typedef pair<int , int> ii;
typedef pair<long long , int> lli;
const int maxN = int(2e5)+7;
const int maxK = 107;
const ll inf = ll(1e18)+7;
int n , k;
pair<int , ll> dp[maxN][maxK] , tmp[maxK];
pair<int , ll> base = {0 , inf};
vector<ii> g[maxN];
pair<int , ll> calc(pair<int , ll> A , pair<int , ll> B){
if (A.fi < B.fi) swap(A , B);
if (A.fi == B.fi) A.se = min(A.se , B.se);
return A;
}
void dfs(int u){
for (auto e : g[u]){
int v = e.fi;
dfs(v);
}
dp[u][0] = {0 , 0};
for (auto e : g[u]){
int v = e.fi;
int w = e.se;
for (int x = 0 ; x <= k ; x++) tmp[x] = base;
for (int x = 0 ; x <= k ; x++){
if (x > 0){
pair<int , ll> val = {dp[u][x - 1].fi + dp[v][k - 1].fi + 1, dp[u][x - 1].se + dp[v][k - 1].se + 1ll * w};
tmp[x] = calc(tmp[x] , val);
}
pair<int , ll> val = {dp[u][x].fi + dp[v][k].fi , dp[u][x].se + dp[v][k].se};
tmp[x] = calc(tmp[x] , val);
}
for (int x = 0 ; x <= k ; x++) dp[u][x] = calc(dp[u][x] , tmp[x]);
for (int x = 1 ; x <= k ; x++){
dp[u][x] = calc(dp[u][x] , dp[u][x - 1]);
}
}
for (int x = 1 ; x <= k ; x++){
dp[u][x] = calc(dp[u][x] , dp[u][x - 1]);
}
}
void solve(){
cin >> n >> k;
for (int i = 2 ; i <= n ; i++){
int x , w; cin >> x >> w;
g[x].push_back({i , w});
}
for (int i = 1 ; i <= n ; i++){
for (int j = 0 ; j <= k + 1 ; j++) dp[i][j] = base;
}
dfs(1);
cout << dp[1][k].fi << " " << dp[1][k].se << "\n";
}
#define name "B"
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
if (fopen(name".INP" , "r")){
freopen(name".INP" , "r" , stdin);
freopen(name".OUT" , "w" , stdout);
}
int t = 1; //cin >> t;
while (t--) solve();
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiNkZWZpbmUgZmkgZmlyc3QKI2RlZmluZSBzZSBzZWNvbmQKI2RlZmluZSBhbGwodikgdi5iZWdpbigpICwgdi5lbmQoKQojZGVmaW5lIHN6KHYpIGludCh2LnNpemUoKSkKI2RlZmluZSB1bnEodikgc29ydChhbGwodikpOyB2LnJlc2l6ZSh1bmlxdWUoYWxsKHYpKSAtIHYuYmVnaW4oKSk7CnVzaW5nIG5hbWVzcGFjZSBzdGQ7Cgp0eXBlZGVmIGxvbmcgbG9uZyBsbDsKdHlwZWRlZiBwYWlyPGludCAsIGludD4gaWk7CnR5cGVkZWYgcGFpcjxsb25nIGxvbmcgLCBpbnQ+IGxsaTsKCmNvbnN0IGludCBtYXhOID0gaW50KDJlNSkrNzsKY29uc3QgaW50IG1heEsgPSAxMDc7CmNvbnN0IGxsIGluZiA9IGxsKDFlMTgpKzc7CgppbnQgbiAsIGs7CnBhaXI8aW50ICwgbGw+IGRwW21heE5dW21heEtdICwgdG1wW21heEtdOwpwYWlyPGludCAsIGxsPiBiYXNlID0gezAgLCBpbmZ9Owp2ZWN0b3I8aWk+IGdbbWF4Tl07CgpwYWlyPGludCAsIGxsPiBjYWxjKHBhaXI8aW50ICwgbGw+IEEgLCBwYWlyPGludCAsIGxsPiBCKXsKICAgIGlmIChBLmZpIDwgQi5maSkgc3dhcChBICwgQik7CiAgICBpZiAoQS5maSA9PSBCLmZpKSBBLnNlID0gbWluKEEuc2UgLCBCLnNlKTsKICAgIHJldHVybiBBOwp9Cgp2b2lkIGRmcyhpbnQgdSl7CiAgICBmb3IgKGF1dG8gZSA6IGdbdV0pewogICAgICAgIGludCB2ID0gZS5maTsKICAgICAgICBkZnModik7CiAgICB9CiAgICBkcFt1XVswXSA9IHswICwgMH07CiAgICBmb3IgKGF1dG8gZSA6IGdbdV0pewogICAgICAgIGludCB2ID0gZS5maTsKICAgICAgICBpbnQgdyA9IGUuc2U7CiAgICAgICAgZm9yIChpbnQgeCA9IDAgOyB4IDw9IGsgOyB4KyspIHRtcFt4XSA9IGJhc2U7CiAgICAgICAgZm9yIChpbnQgeCA9IDAgOyB4IDw9IGsgOyB4KyspewogICAgICAgICAgICBpZiAoeCA+IDApewogICAgICAgICAgICAgICAgcGFpcjxpbnQgLCBsbD4gdmFsID0ge2RwW3VdW3ggLSAxXS5maSArIGRwW3ZdW2sgLSAxXS5maSArIDEsICBkcFt1XVt4IC0gMV0uc2UgKyBkcFt2XVtrIC0gMV0uc2UgKyAxbGwgKiB3fTsKICAgICAgICAgICAgICAgIHRtcFt4XSA9IGNhbGModG1wW3hdICwgdmFsKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBwYWlyPGludCAsIGxsPiB2YWwgPSB7ZHBbdV1beF0uZmkgKyBkcFt2XVtrXS5maSAsICBkcFt1XVt4XS5zZSArIGRwW3ZdW2tdLnNlfTsKICAgICAgICAgICAgdG1wW3hdID0gY2FsYyh0bXBbeF0gLCB2YWwpOwogICAgICAgIH0KICAgICAgICBmb3IgKGludCB4ID0gMCA7IHggPD0gayA7IHgrKykgZHBbdV1beF0gPSBjYWxjKGRwW3VdW3hdICwgdG1wW3hdKTsKICAgICAgICBmb3IgKGludCB4ID0gMSA7IHggPD0gayA7IHgrKyl7CiAgICAgICAgICAgIGRwW3VdW3hdID0gY2FsYyhkcFt1XVt4XSAsIGRwW3VdW3ggLSAxXSk7CiAgICAgICAgfQogICAgfQogICAgZm9yIChpbnQgeCA9IDEgOyB4IDw9IGsgOyB4KyspewogICAgICAgIGRwW3VdW3hdID0gY2FsYyhkcFt1XVt4XSAsIGRwW3VdW3ggLSAxXSk7CiAgICB9Cn0KCnZvaWQgc29sdmUoKXsKICAgIGNpbiA+PiBuID4+IGs7CiAgICBmb3IgKGludCBpID0gMiA7IGkgPD0gbiA7IGkrKyl7CiAgICAgICAgaW50IHggLCB3OyBjaW4gPj4geCA+PiB3OwogICAgICAgIGdbeF0ucHVzaF9iYWNrKHtpICwgd30pOwogICAgfQogICAgZm9yIChpbnQgaSA9IDEgOyBpIDw9IG4gOyBpKyspewogICAgICAgIGZvciAoaW50IGogPSAwIDsgaiA8PSBrICsgMSA7IGorKykgZHBbaV1bal0gPSBiYXNlOwogICAgfQogICAgZGZzKDEpOwogICAgY291dCA8PCBkcFsxXVtrXS5maSA8PCAiICIgPDwgZHBbMV1ba10uc2UgPDwgIlxuIjsKfQoKI2RlZmluZSBuYW1lICJCIgoKaW50IG1haW4oKXsKICAgIGlvc19iYXNlOjpzeW5jX3dpdGhfc3RkaW8oMCk7IGNpbi50aWUoMCk7IGNvdXQudGllKDApOwogICAgaWYgKGZvcGVuKG5hbWUiLklOUCIgLCAiciIpKXsKICAgICAgICBmcmVvcGVuKG5hbWUiLklOUCIgLCAiciIgLCBzdGRpbik7CiAgICAgICAgZnJlb3BlbihuYW1lIi5PVVQiICwgInciICwgc3Rkb3V0KTsKICAgIH0KICAgIGludCB0ID0gMTsgLy9jaW4gPj4gdDsKICAgIHdoaWxlICh0LS0pIHNvbHZlKCk7CiAgICByZXR1cm4gMDsKfQoK