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;
constexpr int N = 1e5 + 10;
long long n, u, v, sz[N], s, ans, fen[N], be, en, l, w;
vector<pair<int, int>> node[N], vec;
bool mark[N];
void add(int x, int val) {
  for (; x <= n; x += x & (-x)) fen[x] += val;
}
int sum(int x) {
  if (x < 0) return 0;
  int ret = 0;
  for (; x; x -= x & (-x)) ret += fen[x];
  return ret;
}
void dfs(int v, int p) {
  sz[v] = 1;
  for (auto i : node[v]) {
    if (i.first != p && !mark[i.first]) {
      dfs(i.first, v);
      sz[v] += sz[i.first];
    }
  }
}
int centroid(int v, int p) {
  for (auto i : node[v]) {
    if (i.first != p && !mark[i.first] && sz[i.first] > s / 2)
      return centroid(i.first, v);
  }
  return v;
}
void addtovec(int v, int p, int nowh, int noww, int keep) {
  vec.push_back({noww, nowh});
  add(nowh, 1);
  if (keep && nowh <= l && noww <= w) ans++;
  for (auto i : node[v])
    if (i.first != p && !mark[i.first])
      addtovec(i.first, v, nowh + 1, noww + i.second, keep);
}
long long compute() {
  long long su = sum(l);
  sort(vec.begin(), vec.end());
  be = 0;
  en = (int)vec.size() - 1;
  while (be <= en) {
    int vazn = vec[be].first;
    int tool = vec[be].second;
    add(tool, -1);
    while (vec[en].first + vazn > w && en >= be) {
      add(vec[en].second, -1);
      en--;
    }
    if (en < be) add(tool, 1);
    su += sum(l - tool);
    be++;
  }
  vec.clear();
  return su;
}
void solve(int v) {
  dfs(v, v);
  s = sz[v];
  int x = centroid(v, v);
  mark[x] = true;
  for (auto i : node[x])
    if (!mark[i.first]) addtovec(i.first, x, 1, i.second, 1);
  ans += compute();
  for (auto i : node[x]) {
    if (!mark[i.first]) {
      addtovec(i.first, x, 1, i.second, 0);
      ans -= compute();
    }
  }
  for (auto i : node[x])
    if (!mark[i.first]) solve(i.first);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> l >> w;
  for (int i = 1; i < n; i++) {
    cin >> u >> v;
    node[u].push_back({i + 1, v});
    node[i + 1].push_back({u, v});
  }
  solve(1);
  cout << ans << '\n';
  return 0;
}