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;
inline int in() {
  int32_t x;
  scanf("%d", &x);
  return x;
}
const int N = 1e5 + 7;
int n, Q, l, w;
vector<int> g[N], gg[N];
int sz[N], mark[N], dis[N], wi[N];
long long ans;
inline int SZ(int x, int par) {
  sz[x] = 1;
  for (auto i : g[x])
    if (i != par && !mark[i]) sz[x] += SZ(i, x);
  return sz[x];
}
inline void DIS(int x, int par) {
  for (int i = 0; i < ((int)g[x].size()); i++)
    if (g[x][i] != par && !mark[g[x][i]]) {
      dis[g[x][i]] = dis[x] + 1;
      wi[g[x][i]] = wi[x] + gg[x][i];
      DIS(g[x][i], x);
    }
}
int fen[N];
inline void add(int x, int y) {
  x++;
  for (int i = x; i < N; i += i & -i) fen[i] += y;
}
inline int get(int x) {
  x++;
  if (x < 1) return 0;
  int res = 0;
  for (int i = x; i; i -= i & -i) res += fen[i];
  return res;
}
vector<pair<int, int> > v;
inline void calc(int sgn) {
  sort(v.begin(), v.end());
  for (auto i : v) add(i.second, 1);
  int pos = ((int)v.size()) - 1;
  for (int i = 0; i < ((int)v.size()); i++) {
    while (v[i].first + v[pos].first > w && pos >= 0) add(v[pos--].second, -1);
    ans += (sgn * 1LL * get(l - v[i].second));
  }
  while (pos >= 0) add(v[pos--].second, -1);
}
inline void dfs(int x, int par) {
  v.push_back({wi[x], dis[x]});
  for (auto i : g[x])
    if (i != par && !mark[i]) dfs(i, x);
}
inline void solve(int x, int par) {
  SZ(x, par);
  int cen = x, pr = par, found = 0;
  while (!found) {
    found = 1;
    for (auto i : g[cen])
      if (!mark[i] && i != pr && sz[i] >= sz[x] / 2) {
        pr = cen;
        cen = i;
        found = 0;
        break;
      }
  }
  mark[cen] = 1;
  dis[cen] = 0;
  wi[cen] = 0;
  DIS(cen, -1);
  vector<pair<int, int> > o;
  for (auto i : g[cen])
    if (!mark[i]) {
      dfs(i, cen);
      calc(-1);
      while (v.size()) {
        o.push_back(v.back());
        v.pop_back();
      }
    }
  o.push_back({0, 0});
  v = o;
  calc(1);
  v.clear();
  for (auto i : g[cen])
    if (!mark[i]) solve(i, cen);
}
int32_t main() {
  n = in(), l = in(), w = in();
  for (int i = 2; i <= n; i++) {
    int x = in(), y = in();
    g[i].push_back(x);
    g[x].push_back(i);
    gg[i].push_back(y);
    gg[x].push_back(y);
  }
  solve(1, -1);
  printf("%I64d\n", (ans - n) / 2);
}