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

//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define pb push_back
#define F first
#define S second
#define lll long long
#define ull unsigned long long
#define lld long double

using namespace std;
using namespace __gnu_pbds;

template <typename T>
using ordered_set = tree <T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

const int N = 3e5 + 229;
const int M = 1e9 + 83;
const int M2 = 1e9 + 7;
const int MM = 1e9 + 7;
const int mod = 998244353;
const int rx[8] = {1, 1, -1, -1, -2, -2, 2, 2};
const int ry[8] = {-2, 2, -2, 2, 1, -1, 1, -1};
const lld eps = 1e-7;
const double pi = acos(-1.0);

lll now[N], want[N], need[N];

vector < pair < int, lll > > g[N];

void solve(int v, int p = -1) {
    for (auto to : g[v]) {
        if (to.F == p) {
            continue;
        }
        solve(to.F, v);
        if (need[to.F] < 0) {
            need[v] += need[to.F];
            need[v] = max(need[v], (lll)(-1e17));
        } else {
            if (1e17 / (1ll * to.S) < need[to.F]) {
                cout << "NO";
                exit(0);
            }
            need[v] += 1ll * need[to.F] * to.S;
        }
    }
    now[v] -= need[v];
    need[v] = 0;
    need[v] += want[v] - now[v];
    if (need[v] > 1e17) {
        cout << "NO";
        exit(0);
    }
    need[v] = max(need[v], (lll)(-1e17));
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    srand(time(0));
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
//    freopen("dictionary.in", "r", stdin);
//    freopen("dictionary.out", "w", stdout);
#endif
    int n, x, y, w;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> now[i];
    }
    for (int i = 0; i < n; ++i) {
        cin >> want[i];
    }
    for (int i = 1; i < n; ++i) {
        cin >> x >> w;
        y = i;
        --x;
        g[x].pb({y, w});
    }
    solve(0);
    if (need[0] <= 0) {
        cout << "YES";
    } else {
        cout << "NO";
    }
    return 0;
}
