Problem: You've got a weighted tree, consisting of n vertices. Each edge has a non-negative weight. The length of the path between any two vertices of the tree is the number of edges in the path. The weight of the path is the total weight of all edges it contains. 

Two vertices are close if there exists a path of length at most l between them and a path of weight at most w between them. Count the number of pairs of vertices v, u (v < u), such that vertices v and u are close.

Input

The first line contains three integers n, l and w (1 ≤ n ≤ 105, 1 ≤ l ≤ n, 0 ≤ w ≤ 109). The next n - 1 lines contain the descriptions of the tree edges. The i-th line contains two integers pi, wi (1 ≤ pi < (i + 1), 0 ≤ wi ≤ 104), that mean that the i-th edge connects vertex (i + 1) and pi and has weight wi.

Consider the tree vertices indexed from 1 to n in some way.

Output

Print a single integer — the number of close pairs.

Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.

Examples

Input

4 4 6
1 3
1 4
1 3


Output

4


Input

6 2 17
1 3
2 5
2 13
1 6
5 9


Output

9

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const int mx = 1e5 + 10;
int l, mark[mx], fen[mx], sub[mx];
long long ans, r;
vector<pair<int, long long> > adj[mx];
vector<pair<long long, int> > now;
int get(int id) {
  int ret = 0;
  if (id < 0) return 0;
  for (id++; id; id -= id & -id) ret += fen[id];
  return ret;
}
void add(int p, int val) {
  for (p++; p < mx; p += p & -p) fen[p] += val;
}
void dfs_size(int v, int par) {
  sub[v] = 1;
  for (auto no : adj[v]) {
    int u = no.first;
    if (!mark[u] && u != par) dfs_size(u, v), sub[v] += sub[u];
  }
}
void dfs_set(int v, int par, long long w, int l) {
  now.push_back(make_pair(w, l));
  for (auto no : adj[v]) {
    int u = no.first;
    long long ww = no.second;
    if (!mark[u] && u != par) dfs_set(u, v, w + ww, l + 1);
  }
}
void solve(int v, long long ty, long long k) {
  now.clear();
  dfs_set(v, 0, 0, 0);
  sort(now.begin(), now.end());
  int r = 0, id = now.size() - 1;
  long long sum = 0, nu = 0;
  while (id >= 0) {
    sum = k - now[id].first;
    while (r < now.size() && r < id && now[r].first <= sum)
      add(now[r].second, 1), r++;
    while (r > id) r--, add(now[r].second, -1);
    nu += get(l - now[id].second);
    id--;
  }
  for (int i = 0; i < r; i++) add(now[i].second, -1);
  ans += ty * (nu);
}
void cende(int v) {
  dfs_size(v, 0);
  int med = v, par = 0;
  while (1) {
    int fou = 1;
    for (auto no : adj[med]) {
      int u = no.first;
      if (!mark[u] && u != par && sub[u] > sub[v] / 2) {
        par = med, med = u, fou = 0;
        break;
      }
    }
    if (fou) break;
  }
  solve(med, 1, r);
  mark[med] = 1;
  l -= 2;
  if (l >= 0)
    for (auto u : adj[med])
      if (!mark[u.first] && r - 2 * u.second >= 0)
        solve(u.first, -1, r - 2 * u.second);
  l += 2;
  for (auto u : adj[med])
    if (!mark[u.first]) cende(u.first);
}
int main() {
  int n, p;
  long long w;
  scanf("%d%d%64Id", &n, &l, &r);
  for (int i = 2; i <= n; i++) {
    scanf("%d%I64d", &p, &w);
    adj[p].push_back(make_pair(i, w));
    adj[i].push_back(make_pair(p, w));
  }
  cende(1);
  printf("%I64d", ans);
  return 0;
}