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>
using namespace std;
template <class c>
struct rge {
  c b, e;
};
template <class c>
rge<c> range(c i, c j) {
  return rge<c>{i, j};
}
template <class c>
auto dud(c* x) -> decltype(cout << *x, 0);
template <class c>
char dud(...);
struct debug {
  ~debug() { cout << endl; }
  template <class c>
  typename enable_if<sizeof dud<c>(0) != 1, debug&>::type operator<<(c i) {
    cout << boolalpha << i;
    return *this;
  }
  template <class c>
  typename enable_if<sizeof dud<c>(0) == 1, debug&>::type operator<<(c i) {
    return *this << range(begin(i), end(i));
  }
  template <class c, class b>
  debug& operator<<(pair<b, c> d) {
    return *this << "(" << d.first << ", " << d.second << ")";
  }
  template <class c>
  debug& operator<<(rge<c> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it;
    return *this << "]";
  }
};
long double eps = (long double)1 / 1e6;
const long double pi = 3.14159265359;
long long inf = 1e18, mod1 = 1e9 + 7;
long long sqr(long long a) { return a * a; }
long long qb(long long a) { return a * a * a; }
long long gcd(long long a, long long b) { return !a ? b : gcd(b % a, a); }
void binary(long long val, int to) {
  for (int i = 0; i < to; i++) cerr << ((1ll << i) & val ? 1 : 0);
  cerr << "\n";
}
long long binpow(long long a, long long b, long long mod) {
  return b ? (b % 2 ? (a * (sqr(binpow(a, b / 2, mod)) % mod)) % mod
                    : sqr(binpow(a, b / 2, mod)) % mod)
           : 1;
}
long long binmult(long long a, long long b, long long mod) {
  return b ? (b % 2 ? (2 * binmult(a, b / 2, mod) + a) % mod
                    : (2 * binmult(a, b / 2, mod)) % mod)
           : 0;
}
const long long R = 1e4;
const long long tx[4] = {1, 0, -1, 0};
const long long ty[4] = {0, 1, 0, -1};
const char rev_to[4] = {'E', 'W', 'N', 'S'};
const int N = 1e5 + 1;
const int M = 1e9 + 1;
void bad() {
  cout << "NO";
  exit(0);
}
vector<pair<int, int> > g[N];
long long a[N], b[N];
int n;
int p[N];
void dfs(int v, int p, long long rb) {
  long long need = 0;
  for (auto& z : g[v]) {
    if (z.first == p) continue;
    dfs(z.first, v, z.second);
  }
  if (a[v] < b[v]) {
    if (v ^ p) b[p] += (b[v] - a[v]) * 1ll * rb;
  } else {
    if (v ^ p) a[p] += (a[v] - b[v]) * 1ll * rb;
  }
  debug() << " ["
          << "v"
             ": "
          << (v) << "] "
          << " ["
          << "a[v]"
             ": "
          << (a[v]) << "] "
          << " ["
          << "b[v]"
             ": "
          << (b[v]) << "] ";
}
signed main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(0);
  ;
  cin >> n;
  fill(p, p + N, -1);
  for (int i = 0; i < n; i++) cin >> b[i];
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 1; i < n; i++) {
    int x, y;
    cin >> x >> y;
    --x;
    g[x].push_back({i, y});
    p[i] = x;
  }
  for (int i = 0; i < n; i++) {
    if (p[i] == -1) {
      dfs(i, i, -1);
    }
  }
  for (int i = 0; i < n; i++) {
    if (b[i] < a[i]) bad();
  }
  cout << "YES";
  return 0;
}
