5
27468 7465 74275 40573 40155
112071 76270 244461 264202 132397
1 777133331
2 107454154
3 652330694
4 792720519
 5
78188 56310 79021 70050 65217
115040 5149 128449 98357 36580
1 451393770
2 574046602
3 590130784
4 112514248
 7
1 1 1 1 1 1 1
1 3000000000 3000000000 3000000000 1000000000 1000000000 1000000000
1 1000000000
1 1000000000
1 1000000000
1 1000000000
1 1000000000
1 1000000000
 10
2 8 6 1 2 7 6 9 2 8
4 9 4 3 5 2 9 3 7 3
1 8
2 8
3 8
4 10
5 1
6 4
7 3
8 10
9 2
 11
1 1 1 1 1 1 1 1 1 1 1
1 1000000001 1000000001 1000000001 1000000001 1000000001 1000000001 1000000001 1000000001 1000000001 1000000001
1 1000000000
1 1000000000
1 1000000000
1 1000000000
1 1000000000
1 1000000000
1 1000000000
1 1000000000
1 1000000000
1 1000000000
 5
2 1 1 2 3
1 2 2 2 1
1 2
1 3
2 4
1 4

NO
 NO
 NO
 YES
 NO
 NO

#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
const long long mod = 1e9 + 7;
int first[400010];
int nex[400010];
int amount = -1;
int go[400010];
__int128 val[400010];
__int128 a[400010];
__int128 b[400010];
int in[400010];
int book[400010];
inline void out(__int128 n) {
  if (n < 0) {
    putchar('-');
    n = -n;
  }
  if (n >= 10) {
    out(n / 10);
  }
  putchar(n % 10 + '0');
}
__int128 read() {
  __int128 x = 0, flag = 0;
  char ch = getchar();
  if (ch == '-') flag = 1;
  while (ch < '0' || ch > '9') ch = getchar();
  while (ch >= '0' && ch <= '9') x *= 10, x += ch - '0', ch = getchar();
  if (flag) return -x;
  return x;
}
void add(int u, int v, __int128 w) {
  go[++amount] = v;
  nex[amount] = first[u];
  first[u] = amount;
  val[amount] = w;
}
__int128 dfs(int now, int fa) {
  int i;
  for (i = first[now]; ~i; i = nex[i]) {
    if (go[i] == fa) continue;
    __int128 temp = dfs(go[i], now);
    if (temp >= 0)
      a[now] += temp / val[i ^ 1];
    else
      a[now] += temp * val[i];
  }
  return a[now];
}
int main() {
  int n;
  cin >> n;
  int i;
  memset(first, -1, sizeof(first));
  for (i = 1; i <= n; i++) b[i] = read();
  for (i = 1; i <= n; i++) {
    a[i] = read();
    a[i] = b[i] - a[i];
  }
  for (i = 2; i <= n; i++) {
    int x;
    __int128 k;
    x = read();
    k = read();
    add(x, i, k);
    add(i, x, 1);
    in[x]++;
    in[i]++;
  }
  __int128 ans = dfs(1, 0);
  if (ans >= 0)
    cout << "YES";
  else
    cout << "NO";
}
