#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
const long long maxn = 112345;
long long n;
vector<pair<long long, long long> > adj[maxn];
long long cCont[1000005];
long long cTime[1000005];
long long tree[4000200][2];
long long val[100005];
pair<long long, long long> query(long long ind, long long l, long long r,
                                 long long ql, long long qr) {
  if (ql > qr) return make_pair(0, 0);
  if (ql == l && qr == r) {
    return make_pair(tree[ind][0], tree[ind][1]);
  }
  long long mid = (l + r) / 2;
  pair<long long, long long> a = query(ind * 2 + 1, l, mid, ql, min(qr, mid));
  pair<long long, long long> b =
      query(ind * 2 + 2, mid + 1, r, max(ql, mid + 1), qr);
  return make_pair(a.first + b.first, a.second + b.second);
}
void update(long long ind, long long l, long long r, long long pos,
            long long added_cookie) {
  if (l == r) {
    tree[ind][0] += added_cookie * l;
    tree[ind][1] += added_cookie;
  } else {
    long long mid = (l + r) / 2;
    if (pos <= mid)
      update(ind * 2 + 1, l, mid, pos, added_cookie);
    else
      update(ind * 2 + 2, mid + 1, r, pos, added_cookie);
    tree[ind][0] = tree[ind * 2 + 1][0] + tree[ind * 2 + 2][0];
    tree[ind][1] = tree[ind * 2 + 1][1] + tree[ind * 2 + 2][1];
  }
}
long long check(long long x, long long t) {
  pair<long long, long long> val = query(0, 0, 1000001, 0, x);
  pair<long long, long long> val2 = query(0, 0, 1000001, x, x);
  if (val.first <= t)
    return val.second;
  else if (val.first - val2.first <= t) {
    long long z = val.second - val2.second;
    long long tleft = t - (val.first - val2.first);
    long long y = tleft / x;
    return z + y;
  }
  return -1;
}
long long dfs(long long s, long long t) {
  if (t < 0) return 0;
  long long val;
  ;
  update(0, 0, 1000001, cTime[s], cCont[s]);
  long long l = 0, r = 1000001, mid;
  while (l < r) {
    long long mid = (l + r + 1) / 2;
    if (check(mid, t) != -1) {
      l = mid;
    } else {
      r = mid - 1;
    }
  }
  val = check(l, t);
  long long high = -200000000000000ll;
  long long secHigh = -200000000000000ll;
  for (auto child : adj[s]) {
    long long to = child.first;
    long long w = child.second;
    long long x = dfs(to, t - 2 * w);
    if (x > high) {
      secHigh = high;
      high = x;
    } else if (x > secHigh) {
      secHigh = x;
    }
  };
  update(0, 0, 1000001, cTime[s], -1 * cCont[s]);
  if (s == 0) return max(high, val);
  return max(secHigh, val);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(10);
  long long n, t, x, y;
  cin >> n >> t;
  for (long long i = 0, _n = (n); i < _n; i++) {
    cin >> cCont[i];
  }
  for (long long i = 0, _n = (n); i < _n; i++) {
    cin >> cTime[i];
  }
  for (long long i = 0, _n = (n - 1); i < _n; i++) {
    cin >> x >> y;
    x--;
    adj[x].push_back(make_pair(i + 1, y));
  }
  cout << dfs(0, t);
}

### Prompt

Your task is to create a CPP solution to the following problem:

Mitya and Vasya are playing an interesting game. They have a rooted tree with n vertices, and the vertices are indexed from 1 to n. The root has index 1. Every other vertex i ≥ 2 has its parent p_i, and vertex i is called a child of vertex p_i.

There are some cookies in every vertex of the tree: there are x_i cookies in vertex i. It takes exactly t_i time for Mitya to eat one cookie in vertex i. There is also a chip, which is initially located in the root of the tree, and it takes l_i time to move the chip along the edge connecting vertex i with its parent.

Mitya and Vasya take turns playing, Mitya goes first.

  * Mitya moves the chip from the vertex, where the chip is located, to one of its children. 
  * Vasya can remove an edge from the vertex, where the chip is located, to one of its children. Vasya can also decide to skip his turn. 

<image>

Mitya can stop the game at any his turn. Once he stops the game, he moves the chip up to the root, eating some cookies along his way. Mitya can decide how many cookies he would like to eat in every vertex on his way. The total time spent on descend, ascend and eating cookies should not exceed T. Please note that in the end of the game the chip is always located in the root of the tree: Mitya can not leave the chip in any other vertex, even if he has already eaten enough cookies — he must move the chip back to the root (and every move from vertex v to its parent takes l_v time).

Find out what is the maximum number of cookies Mitya can eat, regardless of Vasya's actions.

Input

The first line contains two integers n and T — the number of vertices in the tree and the time he has to accomplish his task (2≤ n ≤ 10^5; 1≤ T≤10^{18}).

The second line contains n integers x_1, x_2, ..., x_n — number of cookies located in the corresponding vertex (1≤ x_i≤10^6). The third line contains n integers t_1, t_2, ..., t_n — how much time it takes Mitya to eat one cookie in vertex i (1≤ t_i≤10^6).

Each of the following n - 1 lines describe the tree. For every i from 2 to n, the corresponding line contains two integers p_i and l_i, where p_i denotes the parent of vertex i and l_i denotes the time it takes Mitya to move the chip along the edge from vertex i to its parent (1≤ p_i < i, 0≤ l_i ≤ 10^9).

Output

Output a single integer — maximum number of cookies Mitya can eat.

Examples

Input


5 26
1 5 1 7 7
1 3 2 2 2
1 1
1 1
2 0
2 0


Output


11


Input


3 179
2 2 1
6 6 6
1 3
2 3


Output


4

Note

In the first example test case, Mitya can start by moving the chip to vertex 2. In this case no matter how Vasya plays, Mitya is able to eat at least 11 cookies. Below you can find the detailed description of the moves:

  1. Mitya moves chip to vertex 2. 
  2. Vasya removes edge to vertex 4. 
  3. Mitya moves chip to vertex 5. 
  4. Since vertex 5 has no children, Vasya does not remove any edges. 
  5. Mitya stops the game and moves the chip towards the root, eating cookies along the way (7 in vertex 5, 3 in vertex 2, 1 in vertex 1). 



Mitya spend 1+0 time to go down, 0+1 to go up, 7⋅ 2 to eat 7 cookies in vertex 5, 3⋅ 3 to eat 3 cookies in vertex 2, 1⋅ 1 to eat 1 cookie in vertex 1. Total time is 1+0+0+1+7⋅ 2+3⋅ 3+1⋅ 1=26.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
const long long maxn = 112345;
long long n;
vector<pair<long long, long long> > adj[maxn];
long long cCont[1000005];
long long cTime[1000005];
long long tree[4000200][2];
long long val[100005];
pair<long long, long long> query(long long ind, long long l, long long r,
                                 long long ql, long long qr) {
  if (ql > qr) return make_pair(0, 0);
  if (ql == l && qr == r) {
    return make_pair(tree[ind][0], tree[ind][1]);
  }
  long long mid = (l + r) / 2;
  pair<long long, long long> a = query(ind * 2 + 1, l, mid, ql, min(qr, mid));
  pair<long long, long long> b =
      query(ind * 2 + 2, mid + 1, r, max(ql, mid + 1), qr);
  return make_pair(a.first + b.first, a.second + b.second);
}
void update(long long ind, long long l, long long r, long long pos,
            long long added_cookie) {
  if (l == r) {
    tree[ind][0] += added_cookie * l;
    tree[ind][1] += added_cookie;
  } else {
    long long mid = (l + r) / 2;
    if (pos <= mid)
      update(ind * 2 + 1, l, mid, pos, added_cookie);
    else
      update(ind * 2 + 2, mid + 1, r, pos, added_cookie);
    tree[ind][0] = tree[ind * 2 + 1][0] + tree[ind * 2 + 2][0];
    tree[ind][1] = tree[ind * 2 + 1][1] + tree[ind * 2 + 2][1];
  }
}
long long check(long long x, long long t) {
  pair<long long, long long> val = query(0, 0, 1000001, 0, x);
  pair<long long, long long> val2 = query(0, 0, 1000001, x, x);
  if (val.first <= t)
    return val.second;
  else if (val.first - val2.first <= t) {
    long long z = val.second - val2.second;
    long long tleft = t - (val.first - val2.first);
    long long y = tleft / x;
    return z + y;
  }
  return -1;
}
long long dfs(long long s, long long t) {
  if (t < 0) return 0;
  long long val;
  ;
  update(0, 0, 1000001, cTime[s], cCont[s]);
  long long l = 0, r = 1000001, mid;
  while (l < r) {
    long long mid = (l + r + 1) / 2;
    if (check(mid, t) != -1) {
      l = mid;
    } else {
      r = mid - 1;
    }
  }
  val = check(l, t);
  long long high = -200000000000000ll;
  long long secHigh = -200000000000000ll;
  for (auto child : adj[s]) {
    long long to = child.first;
    long long w = child.second;
    long long x = dfs(to, t - 2 * w);
    if (x > high) {
      secHigh = high;
      high = x;
    } else if (x > secHigh) {
      secHigh = x;
    }
  };
  update(0, 0, 1000001, cTime[s], -1 * cCont[s]);
  if (s == 0) return max(high, val);
  return max(secHigh, val);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(10);
  long long n, t, x, y;
  cin >> n >> t;
  for (long long i = 0, _n = (n); i < _n; i++) {
    cin >> cCont[i];
  }
  for (long long i = 0, _n = (n); i < _n; i++) {
    cin >> cTime[i];
  }
  for (long long i = 0, _n = (n - 1); i < _n; i++) {
    cin >> x >> y;
    x--;
    adj[x].push_back(make_pair(i + 1, y));
  }
  cout << dfs(0, t);
}

```