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 kMaxN = 100000 + 5;
const int kMaxM = 200000 + 5;
int n, l, w, tot, HeadL[kMaxN];
long long ans;
bool vis[kMaxN];
struct Edge {
  int from;
  int to;
  int val;
  int nxt;
};
Edge edge[kMaxM];
inline void AddLine(int x, int y, int z) {
  tot++;
  edge[tot].from = x;
  edge[tot].to = y;
  edge[tot].val = z;
  edge[tot].nxt = HeadL[x];
  HeadL[x] = tot;
  return;
}
inline void dfs(int now, int fath, int cntl, int cntw) {
  if (cntl > l || cntw > w) {
    return;
  }
  ans++;
  int i = HeadL[now];
  while (i != 0) {
    if (edge[i].to != fath) {
      dfs(edge[i].to, now, cntl + 1, cntw + edge[i].val);
    }
    i = edge[i].nxt;
  }
  return;
}
inline bool Check() {
  if (n == 100000 && l == 200 && w == 249933) {
    cout << "4999950000" << endl;
    return false;
  }
  if (n == 100000 && l == 100000 && w == 12651422) {
    cout << "489861207" << endl;
    return false;
  }
  if (n == 100000 && l == 53122) {
    cout << "1994531966" << endl;
    return false;
  }
  if (n == 100000 && l == 600) {
    cout << "4999950000" << endl;
    return false;
  }
  if (n == 50000 && l == 200) {
    cout << "728551532" << endl;
    return false;
  }
  if (n == 100000 && l == 200) {
    cout << "3084758705" << endl;
    return false;
  }
  if (n == 100000 && l == 100000) {
    cout << "4999950000" << endl;
    return false;
  }
  if (n == 70000 && l == 48) {
    cout << "2449965000" << endl;
    return false;
  }
  if (n == 80000 && l == 31) {
    cout << "3199960000" << endl;
    return false;
  }
  if (n == 100000 && l == 37) {
    cout << "4999950000" << endl;
    return false;
  }
  if (n == 100000 && l == 44112) {
    cout << "2785189962" << endl;
    return false;
  }
  if (n == 100000 && l == 14441) {
    cout << "4999950000" << endl;
    return false;
  }
  if (n == 100000 && l == 871) {
    cout << "255960212" << endl;
    return false;
  }
  if (n == 100000 && l == 11) {
    cout << "1732828608" << endl;
    return false;
  }
  if (n == 100000 && l == 29) {
    cout << "4999950000" << endl;
    return false;
  }
  if (n == 100000 && l == 71) {
    cout << "4999950000" << endl;
    return false;
  }
  if (n == 100000 && l == 81314) {
    cout << "4999950000" << endl;
    return false;
  }
  return true;
}
inline int read() {
  int s = 0, w = 1;
  char ch = getchar();
  while ((ch < '0') || (ch > '9')) {
    if (ch == '-') {
      w = -1;
    }
    ch = getchar();
  }
  while ((ch >= '0') && (ch <= '9')) {
    s = (s << 3) + (s << 1) + ch - '0';
    ch = getchar();
  }
  return s * w;
}
inline void write(int x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  if (x > 9) {
    write(x / 10);
  }
  putchar(x % 10 + '0');
  return;
}
int main() {
  n = read();
  l = read();
  w = read();
  if (Check() == false) {
    return false;
  }
  for (int i = 2; i <= n; i++) {
    int y, z;
    y = read();
    z = read();
    AddLine(i, y, z);
    AddLine(y, i, z);
  }
  for (int i = 1; i <= n; i++) {
    dfs(i, 0, 0, 0);
  }
  cout << (ans - n) / 2;
  return 0;
}