#include "bits/stdc++.h"

using namespace std;
using LL = long long;

constexpr int N = 1e5 + 5;
constexpr LL INF = 2e17;

LL have[N], need[N];
int x[N], k[N];

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);

    int n;
    cin >> n;

    for (int i = 1; i <= n; i++) cin >> have[i];
    for (int i = 1; i <= n; i++) cin >> need[i];
    for (int i = 2; i <= n; i++) cin >> x[i] >> k[i];

    for (int i = n; i > 1; i--) {

        if (have[i] < need[i]) {
            LL v = need[i] - have[i];

            if ((__int128) v * k[i] > INF) {
                cout << "NO\n";
                return 0;
            }

            have[x[i]] -= (need[i] - have[i]) * k[i];
            have[i] = need[i];
        }

        if (have[i] > need[i]) {
            have[x[i]] += have[i] - need[i];
        }

        if (have[x[i]] < -INF) {
            cout << "NO\n";
            return 0;
        }
    }

    if (have[1] < need[1]) cout << "NO\n";
    else cout << "YES\n";
}


///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e17;
const int mod=1e9+7;
const int M=100005;
int n;
int ase[M],lagbe[M],x[M],k[M];
 main()

{
    fast
    cin>>n;
    f(i,1,n)cin>>ase[i];
    f(i,1,n)cin>>lagbe[i];
    f(i,2,n)cin>>x[i]>>k[i];
    double lg=17;
    rf(i,n,2)
    {
         if(ase[i]>lagbe[i])
         {
             ase[x[i]]+=(ase[i]-lagbe[i]);
         }
         else if(ase[i]<lagbe[i])
         {
             int nd=lagbe[i]-ase[i];
             double p=log10(nd),q=log10(k[i]);
             if(p+q>lg)
             {
                 cout<<"NO"<<endl;return 0;
             }
             ase[x[i]]-=(nd*k[i]);
             ase[i]=lagbe[i];
         }
         if(ase[i]<-inf)
         {
             cout<<"NO"<<endl;return 0;
         }
    }
    if(ase[1]<lagbe[1])cout<<"NO"<<endl;
    else cout<<"YES"<<endl;
    return 0;

}


///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=100005;
int n;
int ase[M],lagbe[M],x[M],k[M];
 main()

{
    fast
    cin>>n;
    f(i,1,n)cin>>ase[i];
    f(i,1,n)cin>>lagbe[i];
    f(i,2,n)cin>>x[i]>>k[i];
    double lg=18;
    rf(i,n,2)
    {
         if(ase[i]>lagbe[i])
         {
             ase[x[i]]+=(ase[i]-lagbe[i]);
             ase[i]=lagbe[i];
         }
         else if(ase[i]<lagbe[i])
         {
             int nd=lagbe[i]-ase[i];
             double p=log10(nd),q=log10(k[i]);
             if(p+q>lg)
             {
                 cout<<"NO"<<endl;return 0;
             }
             ase[x[i]]-=(nd*k[i]);
             ase[i]=lagbe[i];
         }
         if(ase[i]<-inf)
         {
             cout<<"NO"<<endl;return 0;
         }
    }
    if(ase[1]<lagbe[1])cout<<"NO"<<endl;
    else cout<<"YES"<<endl;
    return 0;

}


///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=2e17;
const int mod=1e9+7;
const int M=100005;
int n;
int ase[M],lagbe[M],x[M],k[M];
 main()

{
    fast
    cin>>n;
    f(i,1,n)cin>>ase[i];
    f(i,1,n)cin>>lagbe[i];
    f(i,2,n)cin>>x[i]>>k[i];
    double lg=log10(inf);
    rf(i,n,2)
    {
         if(ase[i]>lagbe[i])
         {
             ase[x[i]]+=(ase[i]-lagbe[i]);
         }
         else if(ase[i]<lagbe[i])
         {
             int nd=lagbe[i]-ase[i];
             double p=log10(nd),q=log10(k[i]);
             if(p+q>lg)
             {
                 cout<<"NO"<<endl;return 0;
             }
             ase[x[i]]-=(nd*k[i]);
             ase[i]=lagbe[i];
         }
         if(ase[x[i]]<-inf)
         {
             cout<<"NO"<<endl;return 0;
         }
    }
    if(ase[1]<lagbe[1])cout<<"NO"<<endl;
    else cout<<"YES"<<endl;
    return 0;

}


#include <bits/stdc++.h>
using namespace std;
long long a[1000001];
long long b[1000001];
long long k[1000001];
vector<int> adj[1000000];
long long need[1000000];
void dfs(int v)
{
    need[v]=b[v]-a[v];
    for (auto u:adj[v])
    {
        dfs(u);
        if (need[u]>0)
            need[v]+=need[u]*k[u];
        else
            need[v]+=need[u];
    }
}
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);
    int n;
    cin>>n;
    for (int i=1;i<=n;i++)
        cin>>a[i];
    for (int i=1;i<=n;i++)
        cin>>b[i];
    for (int i=2;i<=n;i++)
    {
        int p;
        cin>>p>>k[i];
        adj[p].push_back(i);
    }
    dfs(1);
    if (need[1]<=0)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}


#include <bits/stdc++.h>
using namespace std;
long long a[1000001];
bool ok=1;
long long b[1000001];
long long k[1000001];
vector<int> adj[1000000];
long long need[1000000];
void dfs(int v)
{
    need[v]=b[v]-a[v];
    for (auto u:adj[v])
    {
        dfs(u);
        if (need[u]>0)
        {
            if (100000000000000000LL / need[u] < k[u])
                ok=0;
            need[v]+=need[u]*k[u];
            if (need[v]>100000000000000000LL)
                ok=0;
        }
        else
            need[v]+=need[u];
    }
}
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);
    int n;
    cin>>n;
    for (int i=1;i<=n;i++)
        cin>>a[i];
    for (int i=1;i<=n;i++)
        cin>>b[i];
    for (int i=2;i<=n;i++)
    {
        int p;
        cin>>p>>k[i];
        adj[p].push_back(i);
    }
    dfs(1);
    if (need[1]<=0 && ok)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}


#include <bits/stdc++.h>
using namespace std;
long long a[1000001];
long long b[1000001];
long long k[1000001];
vector<int> adj[1000000];
long long need[1000000];
void pre(int v)
{
    for (auto u:adj[v])
    {
        pre(u);
        if (a[u]>b[u])
            a[v]+=a[u]-b[u],a[u]=b[u];
    }
}
void dfs(int v)
{
    need[v]=max(0LL,b[v]-a[v]);
    for (auto u:adj[v])
    {
        dfs(u);
        need[v]+=need[u]*k[u];
    }
}
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);
    int n;
    cin>>n;
    for (int i=1;i<=n;i++)
        cin>>a[i];
    for (int i=1;i<=n;i++)
        cin>>b[i];
    for (int i=2;i<=n;i++)
    {
        int p;
        cin>>p>>k[i];
        adj[p].push_back(i);
    }
    pre(1);
    dfs(1);
    if (a[1]>=need[1])cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}


#include<stdio.h>
#include<vector>
#include<algorithm>
#include <iostream>
#include <cmath>
#include <complex>
#include<queue>
#include <string>
#include<bits/stdc++.h>
#define pi 3.141592654
#define forr(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define input ios_base::sync_with_stdio(0);cin.tie(0);
//#define x real()
//#define y imag()
using namespace std;
typedef pair<double,double>pdd;
typedef long long  ll;
typedef pair<ll, ll>pii;
//typedef complex<double> point;
//template<typename T>T gcd(T x, T y) { if(y == 0)return x; else return gcd(y, x%y); }
//typedef bitset<21> mask;
//int x[8]={1,0,0,-1,-1,-1,1,1};
//int y[8]={0,1,-1,0,-1,1,-1,1};
//const double PI = acos(-1.0);
//const double EPS = 1e-9;
//typedef complex<double> point;
int n,a[100010],b[1000010],pr[1000010],c[1000010],x,y;
map<pair<int,int>,int>m;
set<pair<int,int>>s;
int main()
{

//cout<<Pow((ll)1000000,(ll)110);a
//freopen("tour.in","r",stdin);
//freopen("output.txt","w",stdout);
//    char input[15];
//    scanf("%s", &input);  array of char
//  gets(c+1);  array of char
input;
cin>>n;
forr(i,1,n)cin>>b[i];
forr(i,1,n)cin>>a[i];

forr(i,2,n)
{
    cin>>x>>y;
    m[{x,i}]=y;
    c[x]++;
    pr[i]=x;
}
forr(i,1,n)
    s.insert({c[i],i});
while((int)s.size()>1)
{
    auto k=*s.begin();
    int val=k.F;
    int u=k.S;
    if(a[u]<=b[u])
    {
        b[pr[u]]+=b[u]-a[u];
    }
    else
    {
        b[pr[u]]-=(a[u]-b[u])*m[{pr[u],u}];
    }
    s.erase(s.begin());
    auto it=s.lower_bound({c[pr[u]],pr[u]});
    s.erase(it);
    c[pr[u]]--;
    s.insert({c[pr[u]],pr[u]});
}
auto p=*s.begin();
if(b[p.S]>=a[p.S])
    cout<<"YES";
else
    cout<<"NO";
return 0;
}


#include<stdio.h>
#include<vector>
#include<algorithm>
#include <iostream>
#include <cmath>
#include <complex>
#include<queue>
#include <string>
#include<bits/stdc++.h>
#define pi 3.141592654
#define forr(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define input ios_base::sync_with_stdio(0);cin.tie(0);
//#define x real()
//#define y imag()
using namespace std;
typedef pair<double,double>pdd;
typedef long long  ll;
typedef pair<ll, ll>pii;
//typedef complex<double> point;
//template<typename T>T gcd(T x, T y) { if(y == 0)return x; else return gcd(y, x%y); }
//typedef bitset<21> mask;
//int x[8]={1,0,0,-1,-1,-1,1,1};
//int y[8]={0,1,-1,0,-1,1,-1,1};
//const double PI = acos(-1.0);
//const double EPS = 1e-9;
//typedef complex<double> point;
ll n,a[100010],pr[100010],c[100010],x,y;
map<pair<ll,ll>,ll>m;
set<pair<ll,ll>>s;
double b[100010];
int main()
{

//cout<<Pow((ll)1000000,(ll)110);a
//freopen("tour.in","r",stdin);
//freopen("output.txt","w",stdout);
//    char input[15];
//    scanf("%s", &input);  array of char
//  gets(c+1);  array of char
input;
cin>>n;
forr(i,1,n)cin>>b[i];
forr(i,1,n)cin>>a[i];

forr(i,2,n)
{
    cin>>x>>y;
    m[{x,i}]=y;
    c[x]++;
    pr[i]=x;
}
forr(i,1,n)
    s.insert({c[i],i});
while((int)s.size()>1)
{
    auto k=*s.begin();
    ll val=k.F;
    ll u=k.S;
    if(a[u]<=b[u])
    {
        b[pr[u]]+=b[u]-a[u];
    }
    else
    {
        b[pr[u]]-=(a[u]-b[u])*m[{pr[u],u}];
    }
    auto it=s.lower_bound({c[pr[u]],pr[u]});
    s.erase(it);
    s.erase(s.begin());
    c[pr[u]]--;
    s.insert({c[pr[u]],pr[u]});
}
auto p=*s.begin();
if(b[p.S]>=a[p.S])
    cout<<"YES";
else
    cout<<"NO";
return 0;
}


#include<stdio.h>
#include<vector>
#include<algorithm>
#include <iostream>
#include <cmath>
#include <complex>
#include<queue>
#include <string>
#include<bits/stdc++.h>
#define pi 3.141592654
#define forr(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define input ios_base::sync_with_stdio(0);cin.tie(0);
//#define x real()
//#define y imag()
using namespace std;
typedef pair<double,double>pdd;
typedef long long  ll;
typedef pair<ll, ll>pii;
//typedef complex<double> point;
//template<typename T>T gcd(T x, T y) { if(y == 0)return x; else return gcd(y, x%y); }
//typedef bitset<21> mask;
//int x[8]={1,0,0,-1,-1,-1,1,1};
//int y[8]={0,1,-1,0,-1,1,-1,1};
//const double PI = acos(-1.0);
//const double EPS = 1e-9;
//typedef complex<double> point;
ll n,a[100010],b[100010],pr[100010],c[100010],x,y;
map<pair<ll,ll>,ll>m;
set<pair<ll,ll>>s;
int main()
{

//cout<<Pow((ll)1000000,(ll)110);a
//freopen("tour.in","r",stdin);
//freopen("output.txt","w",stdout);
//    char input[15];
//    scanf("%s", &input);  array of char
//  gets(c+1);  array of char
input;
cin>>n;
forr(i,1,n)cin>>b[i];
forr(i,1,n)cin>>a[i];

forr(i,2,n)
{
    cin>>x>>y;
    m[{x,i}]=y;
    c[x]++;
    pr[i]=x;
}
forr(i,1,n)
    s.insert({c[i],i});
while((int)s.size()>1)
{
    auto k=*s.begin();
    ll val=k.F;
    ll u=k.S;
    if(a[u]<=b[u])
    {
        b[pr[u]]+=b[u]-a[u];
    }
    else
    {
        if(4e18/(a[u]-b[u])<m[{pr[u],u}])
            {
                cout<<"NO";
                return 0;
            }
        b[pr[u]]-=(a[u]-b[u])*m[{pr[u],u}];
    }
    auto it=s.lower_bound({c[pr[u]],pr[u]});
    s.erase(it);
    s.erase(s.begin());
    c[pr[u]]--;
    s.insert({c[pr[u]],pr[u]});
}
auto p=*s.begin();
if(b[p.S]>=a[p.S])
    cout<<"YES";
else
    cout<<"NO";
return 0;
}


#include<stdio.h>
#include<vector>
#include<algorithm>
#include <iostream>
#include <cmath>
#include <complex>
#include<queue>
#include <string>
#include<bits/stdc++.h>
#define pi 3.141592654
#define forr(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define input ios_base::sync_with_stdio(0);cin.tie(0);
//#define x real()
//#define y imag()
using namespace std;
typedef pair<double,double>pdd;
typedef long long  ll;
typedef pair<ll, ll>pii;
//typedef complex<double> point;
//template<typename T>T gcd(T x, T y) { if(y == 0)return x; else return gcd(y, x%y); }
//typedef bitset<21> mask;
//int x[8]={1,0,0,-1,-1,-1,1,1};
//int y[8]={0,1,-1,0,-1,1,-1,1};
//const double PI = acos(-1.0);
//const double EPS = 1e-9;
//typedef complex<double> point;
ll n,a[100010],b[1000010],pr[1000010],c[1000010],x,y;
map<pair<ll,ll>,ll>m;
set<pair<ll,ll>>s;
int main()
{

//cout<<Pow((ll)1000000,(ll)110);a
//freopen("tour.in","r",stdin);
//freopen("output.txt","w",stdout);
//    char input[15];
//    scanf("%s", &input);  array of char
//  gets(c+1);  array of char
input;
cin>>n;
forr(i,1,n)cin>>b[i];
forr(i,1,n)cin>>a[i];

forr(i,2,n)
{
    cin>>x>>y;
    m[{x,i}]=y;
    c[x]++;
    pr[i]=x;
}
forr(i,1,n)
    s.insert({c[i],i});
while((int)s.size()>1)
{
    auto k=*s.begin();
    ll val=k.F;
    ll u=k.S;
    if(a[u]<=b[u])
    {
        b[pr[u]]+=b[u]-a[u];
    }
    else
    {
        b[pr[u]]-=(a[u]-b[u])*m[{pr[u],u}];
    }
    s.erase(s.begin());
    auto it=s.lower_bound({c[pr[u]],pr[u]});
    s.erase(it);
    c[pr[u]]--;
    s.insert({c[pr[u]],pr[u]});
}
auto p=*s.begin();
if(b[p.S]>=a[p.S])
    cout<<"YES";
else
    cout<<"NO";
return 0;
}


#include<stdio.h>
#include<vector>
#include<algorithm>
#include <iostream>
#include <cmath>
#include <complex>
#include<queue>
#include <string>
#include<bits/stdc++.h>
#define pi 3.141592654
#define forr(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define input ios_base::sync_with_stdio(0);cin.tie(0);
//#define x real()
//#define y imag()
using namespace std;
typedef pair<double,double>pdd;
typedef long long  ll;
typedef pair<ll, ll>pii;
//typedef complex<double> point;
//template<typename T>T gcd(T x, T y) { if(y == 0)return x; else return gcd(y, x%y); }
//typedef bitset<21> mask;
//int x[8]={1,0,0,-1,-1,-1,1,1};
//int y[8]={0,1,-1,0,-1,1,-1,1};
//const double PI = acos(-1.0);
//const double EPS = 1e-9;
//typedef complex<double> point;
ll n,a[100010],b[100010],pr[100010],c[100010],x,y;
map<pair<ll,ll>,ll>m;
set<pair<ll,ll>>s;
int main()
{

//cout<<Pow((ll)1000000,(ll)110);a
//freopen("tour.in","r",stdin);
//freopen("output.txt","w",stdout);
//    char input[15];
//    scanf("%s", &input);  array of char
//  gets(c+1);  array of char
input;
cin>>n;
forr(i,1,n)cin>>b[i];
forr(i,1,n)cin>>a[i];

forr(i,2,n)
{
    cin>>x>>y;
    m[{x,i}]=y;
    c[x]++;
    pr[i]=x;
}
forr(i,1,n)
    s.insert({c[i],i});
while((int)s.size()>1)
{
    auto k=*s.begin();
    ll val=k.F;
    ll u=k.S;
    if(a[u]<=b[u])
    {
        b[pr[u]]+=b[u]-a[u];
    }
    else
    {
        b[pr[u]]-=(a[u]-b[u])*m[{pr[u],u}];
    }
    auto it=s.lower_bound({c[pr[u]],pr[u]});
    s.erase(it);
    s.erase(s.begin());
    c[pr[u]]--;
    s.insert({c[pr[u]],pr[u]});
}
auto p=*s.begin();
if(b[p.S]>=a[p.S])
    cout<<"YES";
else
    cout<<"NO";
return 0;
}


#include<stdio.h>
#include<vector>
#include<algorithm>
#include <iostream>
#include <cmath>
#include <complex>
#include<queue>
#include <string>
#include<bits/stdc++.h>
#define pi 3.141592654
#define forr(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define input ios_base::sync_with_stdio(0);cin.tie(0);
//#define x real()
//#define y imag()
using namespace std;
typedef pair<double,double>pdd;
typedef long long  ll;
typedef pair<ll, ll>pii;
//typedef complex<double> point;
//template<typename T>T gcd(T x, T y) { if(y == 0)return x; else return gcd(y, x%y); }
//typedef bitset<21> mask;
//int x[8]={1,0,0,-1,-1,-1,1,1};
//int y[8]={0,1,-1,0,-1,1,-1,1};
//const double PI = acos(-1.0);
//const double EPS = 1e-9;
//typedef complex<double> point;
ll n,a[100010],b[100010],pr[100010],c[100010],x,y;
map<pair<ll,ll>,ll>m;
set<pair<ll,ll>>s;
int main()
{

//cout<<Pow((ll)1000000,(ll)110);a
//freopen("tour.in","r",stdin);
//freopen("output.txt","w",stdout);
//    char input[15];
//    scanf("%s", &input);  array of char
//  gets(c+1);  array of char
input;
cin>>n;
forr(i,1,n)cin>>b[i];
forr(i,1,n)cin>>a[i];

forr(i,2,n)
{
    cin>>x>>y;
    m[{x,i}]=y;
    c[x]++;
    pr[i]=x;
}
forr(i,1,n)
    s.insert({c[i],i});
while((int)s.size()>1)
{
    auto k=*s.begin();
    ll val=k.F;
    ll u=k.S;
    if(a[u]<=b[u])
    {
        if(4e18/(b[u]-a[u])<b[pr[u]])
        {
               cout<<"NO";
               return 0;
        }
        b[pr[u]]+=b[u]-a[u];
    }
    else
    {
        if((4e18/(a[u]-b[u])<m[{pr[u],u}])||(4e18/((a[u]-b[u])*m[{pr[u],u}])<b[pr[u]]))
            {
                cout<<"NO";
                return 0;
            }
        b[pr[u]]-=(a[u]-b[u])*m[{pr[u],u}];
    }
    auto it=s.lower_bound({c[pr[u]],pr[u]});
    s.erase(it);
    s.erase(s.begin());
    c[pr[u]]--;
    s.insert({c[pr[u]],pr[u]});
}
auto p=*s.begin();
if(b[p.S]>=a[p.S])
    cout<<"YES";
else
    cout<<"NO";
return 0;
}


/// Code by Leonardo16
///   “It is not the strength of the body, but the strength of the spirit.”   —  J.R.R. Tolkien
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
/// Macros
#define int long long
#define ll long long
#define sz size
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define ii pair<int,int>
#define vii vector<ii>
#define fst first
#define scd second
#define pb push_back
#define fl '\n'
#define el endl
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
/// Functions
#define db(x) cerr << #x << ": " << (x) << '\n';
#define random() __builtin_ia32_rdtsc()
#define lg2(x) 31-__builtin_clz(x)
#define lg2ll(x) 63-__builtin_clzll(x)
#define pi acos(-1)
#define YN(x) cout<<((x)?("YES"):("NO"))<<fl;
#define yn(x) cout<<((x)?("Yes"):("No"))<<fl;
/// Red-Black Tree Template
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
//#define less_than(n) order_of_key(n)
//#define en_pos(n) find_by_order(n)
/// Prime numbers  173,179,311,331,737,1009,2011,2027,3079,4001,100003
///===================================================================
int n;
vii g[100005];
int a[100005],b[100005];
int up[100005],dw[100005];
bool can=true;

void dfs(int u,int p,int ch){
    if(a[u]>b[u]){
        dw[u]+=a[u]-b[u];
    }else{
        up[u]+=abs(a[u]-b[u]);
    }
    for(auto v:g[u]){
        if(v.fst==p)continue;
        dfs(v.fst,u,v.scd);
        up[u]+=up[v.fst];
        dw[u]+=dw[v.fst];
    }
    int mi=min(dw[u],up[u]);
    dw[u]-=mi;
    up[u]-=mi;

    if(ch!=-1&& up[u]%ch!=0 ){
        can=false;
    }

    if(ch==-1){
        if(up[u]!=dw[u])can=false;
    }else{
        up[u]=up[u]/ch;
        dw[u]=dw[u]*ch;
    }
}

main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>b[i];
    }
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    for(int i=2;i<=n;i++){
        int b,x;
        cin>>b>>x;
        g[i].pb({b,x});
        g[b].pb({i,x});
    }

    dfs(1,-1,-1);

    YN(can);

return 0;}


/// Code by Leonardo16
///   “It is not the strength of the body, but the strength of the spirit.”   —  J.R.R. Tolkien
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
/// Macros
#define int long long
#define ll long long
#define sz size
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define ii pair<int,int>
#define vii vector<ii>
#define fst first
#define scd second
#define pb push_back
#define fl '\n'
#define el endl
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
/// Functions
#define db(x) cerr << #x << ": " << (x) << '\n';
#define random() __builtin_ia32_rdtsc()
#define lg2(x) 31-__builtin_clz(x)
#define lg2ll(x) 63-__builtin_clzll(x)
#define pi acos(-1)
#define YN(x) cout<<((x)?("YES"):("NO"))<<fl;
#define yn(x) cout<<((x)?("Yes"):("No"))<<fl;
/// Red-Black Tree Template
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
//#define less_than(n) order_of_key(n)
//#define en_pos(n) find_by_order(n)
/// Prime numbers  173,179,311,331,737,1009,2011,2027,3079,4001,100003
///===================================================================
int n;
vii g[100005];
int a[100005],b[100005];
int up[100005],dw[100005];
bool can=true;

void dfs(int u,int p,int ch){
    for(auto v:g[u]){
        if(v.fst==p)continue;
        dfs(v.fst,u,v.scd);
    }

//    cout<<u<<" "<<b[u]<<" "<<a[u]<<fl;
    if( ch!=-1 ){
        if(a[u]>b[u]){
            int cnt=a[u]-b[u];
            b[p]-=ch*cnt;
        }else{
            int cnt=b[u]-a[u];
            b[p]+=cnt*ch;
        }
    }else{
        if(b[u]>=a[u]){
            can=true;
        }else{
            can=false;
        }
    }
}

main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>b[i];
    }
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    for(int i=2;i<=n;i++){
        int b,x;
        cin>>b>>x;
        g[i].pb({b,x});
        g[b].pb({i,x});
    }

    dfs(1,-1,-1);

    YN(can);

return 0;}


/// Code by Leonardo16
///   “It is not the strength of the body, but the strength of the spirit.”   —  J.R.R. Tolkien
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
/// Macros
#define int long long
#define ll long long
#define sz size
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define ii pair<int,int>
#define vii vector<ii>
#define fst first
#define scd second
#define pb push_back
#define fl '\n'
#define el endl
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
/// Functions
#define db(x) cerr << #x << ": " << (x) << '\n';
#define random() __builtin_ia32_rdtsc()
#define lg2(x) 31-__builtin_clz(x)
#define lg2ll(x) 63-__builtin_clzll(x)
#define pi acos(-1)
#define YN(x) cout<<((x)?("YES"):("NO"))<<fl;
#define yn(x) cout<<((x)?("Yes"):("No"))<<fl;
/// Red-Black Tree Template
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
//#define less_than(n) order_of_key(n)
//#define en_pos(n) find_by_order(n)
/// Prime numbers  173,179,311,331,737,1009,2011,2027,3079,4001,100003
///===================================================================
int n;
vii g[100005];
int a[100005],b[100005];
int up[100005],dw[100005];
bool can=true;

void dfs(int u,int p,int ch){
    for(auto v:g[u]){
        if(v.fst==p)continue;
        dfs(v.fst,u,v.scd);
    }

    if(b[i]<=2*-1e17){
        can=false;
    }
//    cout<<u<<" "<<b[u]<<" "<<a[u]<<fl;
    if( ch!=-1 ){
        if(a[u]>b[u]){
            int cnt=a[u]-b[u];
            b[p]-=ch*cnt;
        }else{
            int cnt=b[u]-a[u];
            b[p]+=cnt;
        }
    }else{
        if(b[u]>=a[u]){
            can=true;
        }else{
            can=false;
        }
    }
}

main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>b[i];
    }
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    for(int i=2;i<=n;i++){
        int b,x;
        cin>>b>>x;
        g[i].pb({b,x});
        g[b].pb({i,x});
    }

    dfs(1,-1,-1);

    YN(can);

return 0;}


/// Code by Leonardo16
///   “It is not the strength of the body, but the strength of the spirit.”   —  J.R.R. Tolkien
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
/// Macros
#define int long long
#define ll long long
#define sz size
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define ii pair<int,int>
#define vii vector<ii>
#define fst first
#define scd second
#define pb push_back
#define fl '\n'
#define el endl
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
/// Functions
#define db(x) cerr << #x << ": " << (x) << '\n';
#define random() __builtin_ia32_rdtsc()
#define lg2(x) 31-__builtin_clz(x)
#define lg2ll(x) 63-__builtin_clzll(x)
#define pi acos(-1)
#define YN(x) cout<<((x)?("YES"):("NO"))<<fl;
#define yn(x) cout<<((x)?("Yes"):("No"))<<fl;
/// Red-Black Tree Template
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
//#define less_than(n) order_of_key(n)
//#define en_pos(n) find_by_order(n)
/// Prime numbers  173,179,311,331,737,1009,2011,2027,3079,4001,100003
///===================================================================
int n;
vii g[100005];
int a[100005],b[100005];
int up[100005],dw[100005];
bool can=true;

void dfs(int u,int p,int ch){
    for(auto v:g[u]){
        if(v.fst==p)continue;
        dfs(v.fst,u,v.scd);
    }

//    cout<<u<<" "<<b[u]<<" "<<a[u]<<fl;
    if( ch!=-1 ){
        if(a[u]>b[u]){
            int cnt=a[u]-b[u];
            b[p]-=ch*cnt;
        }else{
            int cnt=b[u]-a[u];
            b[p]+=cnt;
        }
    }else{
        if(b[u]>=a[u]){
            can=true;
        }else{
            can=false;
        }
    }
}

main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>b[i];
    }
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    for(int i=2;i<=n;i++){
        int b,x;
        cin>>b>>x;
        g[i].pb({b,x});
        g[b].pb({i,x});
    }

    dfs(1,-1,-1);

    YN(can);

return 0;}


/// Code by Leonardo16
///   “It is not the strength of the body, but the strength of the spirit.”   —  J.R.R. Tolkien
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
/// Macros
#define int long long
#define ll long long
#define sz size
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define ii pair<int,int>
#define vii vector<ii>
#define fst first
#define scd second
#define pb push_back
#define fl '\n'
#define el endl
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
/// Functions
#define db(x) cerr << #x << ": " << (x) << '\n';
#define random() __builtin_ia32_rdtsc()
#define lg2(x) 31-__builtin_clz(x)
#define lg2ll(x) 63-__builtin_clzll(x)
#define pi acos(-1)
#define YN(x) cout<<((x)?("YES"):("NO"))<<fl;
#define yn(x) cout<<((x)?("Yes"):("No"))<<fl;
/// Red-Black Tree Template
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
//#define less_than(n) order_of_key(n)
//#define en_pos(n) find_by_order(n)
/// Prime numbers  173,179,311,331,737,1009,2011,2027,3079,4001,100003
///===================================================================
int n;
vii g[100005];
int a[100005],b[100005];
int up[100005],dw[100005];
bool can=true;

void dfs(int u,int p,int ch){
    for(auto v:g[u]){
        if(v.fst==p)continue;
        dfs(v.fst,u,v.scd);
    }

    if(b[u]<=2*-1e17){
        can=false;
    }

    if( ch!=-1 ){
        if(a[u]>b[u]){
            int cnt=a[u]-b[u];
            if(ch*cnt <=2*-1e17){
                can=false;
            }
            b[p]-=ch*cnt;
        }else{
            int cnt=b[u]-a[u];
            b[p]+=cnt;
            if(b[p]<=2*-1e17){
                can=false;
            }
        }
    }else{
        if(b[u]<a[u]){
            can=false;
        }
    }
}

main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>b[i];
    }
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    for(int i=2;i<=n;i++){
        int b,x;
        cin>>b>>x;
        g[i].pb({b,x});
        g[b].pb({i,x});
    }

    dfs(1,-1,-1);

    YN(can);

return 0;}


/// Code by Leonardo16
///   “It is not the strength of the body, but the strength of the spirit.”   —  J.R.R. Tolkien
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
/// Macros
#define int long long
#define ll long long
#define sz size
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define ii pair<int,int>
#define vii vector<ii>
#define fst first
#define scd second
#define pb push_back
#define fl '\n'
#define el endl
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
/// Functions
#define db(x) cerr << #x << ": " << (x) << '\n';
#define random() __builtin_ia32_rdtsc()
#define lg2(x) 31-__builtin_clz(x)
#define lg2ll(x) 63-__builtin_clzll(x)
#define pi acos(-1)
#define YN(x) cout<<((x)?("YES"):("NO"))<<fl;
#define yn(x) cout<<((x)?("Yes"):("No"))<<fl;
/// Red-Black Tree Template
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
//#define less_than(n) order_of_key(n)
//#define en_pos(n) find_by_order(n)
/// Prime numbers  173,179,311,331,737,1009,2011,2027,3079,4001,100003
///===================================================================
int n;
vii g[100005];
int a[100005],b[100005];
int up[100005],dw[100005];
bool can=true;

int mult(int a,int b){
    if(b==1)return a;
    if(b==0)return 0;
    int ret=mult(a,b/2);
    if(ret<=2*-1e17)can=false;
    if(b%2==0){
        return ret+ret;
    }else{
        return ret+ret+a;
    }
}

void dfs(int u,int p,int ch){
    for(auto v:g[u]){
        if(v.fst==p)continue;
        dfs(v.fst,u,v.scd);
    }

    if(b[u]<=2*-1e17){
        can=false;
    }

    if( ch!=-1 ){
        if(a[u]>b[u]){
            int cnt=a[u]-b[u];
            if(mult(ch,cnt) <=2*-1e17){
                can=false;
            }
            b[p]-=ch*cnt;
            if( b[p] <=2*-1e17){
                can=false;
            }
        }else{
            int cnt=b[u]-a[u];
            b[p]+=cnt;
            if(b[p]<=2*-1e17){
                can=false;
            }
        }
    }else{
        if(b[u]<a[u]){
            can=false;
        }
    }
}

main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>b[i];
    }
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    for(int i=2;i<=n;i++){
        int b,x;
        cin>>b>>x;
        g[i].pb({b,x});
        g[b].pb({i,x});
    }

    dfs(1,-1,-1);

    YN(can);

return 0;}


/// Code by Leonardo16
///   “It is not the strength of the body, but the strength of the spirit.”   —  J.R.R. Tolkien
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
/// Macros
#define int long long
#define ll long long
#define sz size
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define ii pair<int,int>
#define vii vector<ii>
#define fst first
#define scd second
#define pb push_back
#define fl '\n'
#define el endl
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
/// Functions
#define db(x) cerr << #x << ": " << (x) << '\n';
#define random() __builtin_ia32_rdtsc()
#define lg2(x) 31-__builtin_clz(x)
#define lg2ll(x) 63-__builtin_clzll(x)
#define pi acos(-1)
#define YN(x) cout<<((x)?("YES"):("NO"))<<fl;
#define yn(x) cout<<((x)?("Yes"):("No"))<<fl;
/// Red-Black Tree Template
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
//#define less_than(n) order_of_key(n)
//#define en_pos(n) find_by_order(n)
/// Prime numbers  173,179,311,331,737,1009,2011,2027,3079,4001,100003
///===================================================================
int n;
vii g[100005];
int a[100005],b[100005];
int up[100005],dw[100005];
bool can=true;

void dfs(int u,int p,int ch){
    for(auto v:g[u]){
        if(v.fst==p)continue;
        dfs(v.fst,u,v.scd);
    }

    if(b[u]<=2*-1e17){
        can=false;
    }
//    cout<<u<<" "<<b[u]<<" "<<a[u]<<fl;
    if( ch!=-1 ){
        if(a[u]>b[u]){
            int cnt=a[u]-b[u];
            b[p]-=ch*cnt;
        }else{
            int cnt=b[u]-a[u];
            b[p]+=cnt;
        }
    }else{
        if(b[u]>=a[u]){
            can=true;
        }else{
            can=false;
        }
    }
}

main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>b[i];
    }
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    for(int i=2;i<=n;i++){
        int b,x;
        cin>>b>>x;
        g[i].pb({b,x});
        g[b].pb({i,x});
    }

    dfs(1,-1,-1);

    YN(can);

return 0;}


/// Code by Leonardo16
///   “It is not the strength of the body, but the strength of the spirit.”   —  J.R.R. Tolkien
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
/// Macros
#define int long long
#define ll long long
#define sz size
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define ii pair<int,int>
#define vii vector<ii>
#define fst first
#define scd second
#define pb push_back
#define fl '\n'
#define el endl
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
/// Functions
#define db(x) cerr << #x << ": " << (x) << '\n';
#define random() __builtin_ia32_rdtsc()
#define lg2(x) 31-__builtin_clz(x)
#define lg2ll(x) 63-__builtin_clzll(x)
#define pi acos(-1)
#define YN(x) cout<<((x)?("YES"):("NO"))<<fl;
#define yn(x) cout<<((x)?("Yes"):("No"))<<fl;
/// Red-Black Tree Template
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
//#define less_than(n) order_of_key(n)
//#define en_pos(n) find_by_order(n)
/// Prime numbers  173,179,311,331,737,1009,2011,2027,3079,4001,100003
///===================================================================
int n;
vii g[100005];
int a[100005],b[100005];
int up[100005],dw[100005];
bool can=true;

int mult(int a,int b){
    int ret=mult(a,b/2);
    if(ret<=2*-1e17)can=false;
    if(b%2==0){
        return ret+ret;
    }else{
        return ret+ret+a;
    }
}

void dfs(int u,int p,int ch){
    for(auto v:g[u]){
        if(v.fst==p)continue;
        dfs(v.fst,u,v.scd);
    }

    if(b[u]<=2*-1e17){
        can=false;
    }

    if( ch!=-1 ){
        if(a[u]>b[u]){
            int cnt=a[u]-b[u];
            if(mult(ch,cnt) <=2*-1e17){
                can=false;
            }
            b[p]-=ch*cnt;
            if( b[p] <=2*-1e17){
                can=false;
            }
        }else{
            int cnt=b[u]-a[u];
            b[p]+=cnt;
            if(b[p]<=2*-1e17){
                can=false;
            }
        }
    }else{
        if(b[u]<a[u]){
            can=false;
        }
    }
}

main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>b[i];
    }
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    for(int i=2;i<=n;i++){
        int b,x;
        cin>>b>>x;
        g[i].pb({b,x});
        g[b].pb({i,x});
    }

    dfs(1,-1,-1);

    YN(can);

return 0;}


#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define pb push_back
#define pf pop_front
#define mp make_pair
#define mod 1000000007
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mat vector<vector<int>>
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define fo(i,n) for(int i=0;i<n;i++)
#define inp(a) int a;cin>>a;
#define inpa(a,n)vector<int> a(n);fo(i,n)cin>>a[i];
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
using namespace std;
#define int ll

auto sum(auto a){auto ans=0;for(auto i:a)ans+=i;return ans;}

int n;
vector<int> a,b;
vector<pair<int,int>> conn[100000];
bool done[100000];
int diff;

int dfs1(int root,int ev)		//give ev of parent for 1 of node
{
	if(diff<0)
	{
		cout<<"NO\n";
		exit(0);
	}
	done[root]=1;
	for(pair<int,int> i:conn[root])
	{
		if(!done[i.F])
		{
			a[root]+=dfs1(i.F,i.S);
		}
	}
	if(a[root]<b[root])
	{
		if(ev>0)
		{
			if((diff+b[root]+a[root])/ev<b[root]-a[root])
			{
				cout<<"NO\n";
				exit(0);
			}
			diff-=(a[root]+(b[root]-a[root])*ev)-(b[root]);
			return (a[root]-b[root])*ev;
		}
		else
		{
			return a[root]-b[root];
		}
	}
	else
	{
		if(ev>0)
		{
			return a[root]-b[root];
		}
		else
		{
			diff-=a[root]-(b[root]+(a[root]-b[root])/(-ev));
			return (a[root]-b[root])/(-ev);
		}
	}
}

signed main()
{
	fio
	cin>>n;
	a.resize(n);
	b.resize(n);
	fo(i,n)
		cin>>a[i];
	fo(i,n)
		cin>>b[i];
	diff=sum(a)-sum(b);
	fo(i,n-1)
	{
		inp(x) inp(k)
		x--;
		conn[i+1].pb(mp(x,-k));
		conn[x].pb(mp(i+1,k));
	}
	memset(done,0,sizeof(done));
	if(dfs1(0,1)<0)
		cout<<"NO\n";
	else
		cout<<"YES\n";
	printclock;
}


#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define pb push_back
#define pf pop_front
#define mp make_pair
#define mod 1000000007
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mat vector<vector<int>>
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define fo(i,n) for(int i=0;i<n;i++)
#define inp(a) int a;cin>>a;
#define inpa(a,n)vector<int> a(n);fo(i,n)cin>>a[i];
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
using namespace std;
#define int ll

auto max(auto a){auto ans=a[0];for(auto i:a)if(i>ans)ans=i;return ans;}
auto min(auto a){auto ans=a[0];for(auto i:a)if(i<ans)ans=i;return ans;}
void print(auto a){for(auto i:a)cerr<<i<<' ';cerr<<'\n';}

int n;
vector<int> a,b;
vector<pair<int,int>> conn[100000];
bool done[100000];

int dfs1(int root,int ev)		//give ev of parent for 1 of node
{
	done[root]=1;
	for(pair<int,int> i:conn[root])
	{
		if(!done[i.F])
		{
			a[root]+=dfs1(i.F,i.S);
		}
	}
	if(a[root]<b[root])
	{
		if(ev>0)
		{
			return (a[root]-b[root])*ev;
		}
		else
		{
			return a[root]-b[root];
		}
	}
	else
	{
		if(ev>0)
		{
			return a[root]-b[root];
		}
		else
		{
			return (a[root]-b[root])/(-ev);
		}
	}
}

signed main()
{
	fio
	cin>>n;
	a.resize(n);
	b.resize(n);
	fo(i,n)
		cin>>a[i];
	fo(i,n)
		cin>>b[i];
	fo(i,n-1)
	{
		inp(x) inp(k)
		x--;
		conn[i+1].pb(mp(x,-k));
		conn[x].pb(mp(i+1,k));
	}
	memset(done,0,sizeof(done));
	if(dfs1(0,1)<0)
		cout<<"NO\n";
	else
		cout<<"YES\n";
	printclock;
}


#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define pb push_back
#define pf pop_front
#define mp make_pair
#define mod 1000000007
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mat vector<vector<int>>
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define fo(i,n) for(int i=0;i<n;i++)
#define inp(a) int a;cin>>a;
#define inpa(a,n)vector<int> a(n);fo(i,n)cin>>a[i];
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
using namespace std;
#define int ll

void print(auto a){for(auto i:a)cerr<<i<<' ';cerr<<'\n';}

int n;
vector<int> a,b;
vector<int> conn[100000];
bool done[100000];
map<pair<int,int>,int> cost;

int dfs1(int root,int par)
{
	done[root]=1;
	for(int i:conn[root])
	{
		if(!done[i])
		{
			a[root]+=dfs1(i,root);
		}
	}
	if(a[root]<b[root])
	{
		return (a[root]-b[root])*cost[mp(par,root)];
	}
	else
	{
		return (a[root]-b[root])/cost[mp(root,par)];
	}
}

signed main()
{
	fio
	cin>>n;
	a.resize(n);
	b.resize(n);
	fo(i,n)
		cin>>a[i];
	fo(i,n)
		cin>>b[i];
	cost[mp((int)0,(int)0)]=1;
	fo(i,n-1)
	{
		inp(x) inp(k)
		x--;
		conn[i+1].pb(x);
		conn[x].pb(i+1);
		cost[mp(i+1,x)]=1;
		cost[mp(x,i+1)]=k;
	}
	memset(done,0,sizeof(done));
	if(dfs1(0,0)<0)
		cout<<"NO\n";
	else
		cout<<"YES\n";
	printclock;
}


#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define pb push_back
#define pf pop_front
#define mp make_pair
#define mod 1000000007
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mat vector<vector<int>>
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define fo(i,n) for(int i=0;i<n;i++)
#define inp(a) int a;cin>>a;
#define inpa(a,n)vector<int> a(n);fo(i,n)cin>>a[i];
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
using namespace std;
#define int ll

auto max(auto a){auto ans=a[0];for(auto i:a)if(i>ans)ans=i;return ans;}
auto min(auto a){auto ans=a[0];for(auto i:a)if(i<ans)ans=i;return ans;}
void print(auto a){for(auto i:a)cerr<<i<<' ';cerr<<'\n';}

int n;
vector<int> a,b;
vector<pair<int,int>> conn[100000];
bool done[100000];

int dfs1(int root,int ev)
{
	done[root]=1;
	for(pair<int,int> i:conn[root])
	{
		if(!done[i.F])
		{
			a[root]+=dfs1(i.F,i.S);
		}
	}
	if(a[root]<b[root])
	{
	//	cout<<ev<<"  ";
	//	cout<<root+1<<','<<(a[root]-b[root])*ev<<endl;
		return (a[root]-b[root])*ev;
	}
	else
	{
	//	cout<<ev<<"  ";
	//	cout<<root+1<<'.'<<(a[root]-b[root])/ev<<endl;
		return (a[root]-b[root])/ev;
	}
}

signed main()
{
	fio
	cin>>n;
	a.resize(n);
	b.resize(n);
	fo(i,n)
		cin>>a[i];
	fo(i,n)
		cin>>b[i];
	fo(i,n-1)
	{
		inp(x) inp(k)
		x--;
		conn[i+1].pb(mp(x,(int)1));
		conn[x].pb(mp(i+1,k));
	}
	memset(done,0,sizeof(done));
	if(dfs1(0,1)<0)
		cout<<"NO\n";
	else
		cout<<"YES\n";
	printclock;
}


#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define pb push_back
#define pf pop_front
#define mp make_pair
#define mod 1000000007
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mat vector<vector<int>>
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define fo(i,n) for(int i=0;i<n;i++)
#define inp(a) int a;cin>>a;
#define inpa(a,n)vector<int> a(n);fo(i,n)cin>>a[i];
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
using namespace std;
#define int ll

auto max(auto a){auto ans=a[0];for(auto i:a)if(i>ans)ans=i;return ans;}
auto min(auto a){auto ans=a[0];for(auto i:a)if(i<ans)ans=i;return ans;}
void print(auto a){for(auto i:a)cerr<<i<<' ';cerr<<'\n';}

int n;
vector<int> a,b;
vector<pair<int,int>> conn[100000];
bool done[100000];

int dfs1(int root,int par,int ev)
{
	done[root]=1;
	for(pair<int,int> i:conn[root])
	{
		if(!done[i.F])
		{
			a[root]+=dfs1(i.F,root,i.S);
		}
	}
	if(a[root]<b[root])
	{
		if(root==0)
			cout<<"NO\n";
		return (a[root]-b[root])*ev;
	}
	else
	{
		if(root==0)
			cout<<"YES\n";
		int ind=lower_bound(all(conn[root]),mp(par,(int)0))-conn[root].begin();
		ev=conn[root][ind].S;
		return (a[root]-b[root])*ev;
	}
}

signed main()
{
	fio
	cin>>n;
	a.resize(n);
	b.resize(n);
	fo(i,n)
		cin>>a[i];
	fo(i,n)
		cin>>b[i];
	fo(i,n-1)
	{
		inp(x) inp(k)
		x--;
		conn[i+1].pb(mp(x,(int)1));
		conn[x].pb(mp(i+1,k));
	}
	memset(done,0,sizeof(done));
	dfs1(0,0,1);
	printclock;
}


#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define pb push_back
#define pf pop_front
#define mp make_pair
#define mod 1000000007
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mat vector<vector<int>>
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define fo(i,n) for(int i=0;i<n;i++)
#define inp(a) int a;cin>>a;
#define inpa(a,n)vector<int> a(n);fo(i,n)cin>>a[i];
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
using namespace std;
#define int ll

auto sum(auto a){auto ans=0;for(auto i:a)ans+=i;return ans;}

int n;
vector<int> a,b;
vector<pair<int,int>> conn[100000];
bool done[100000];
int diff;

int dfs1(int root,int ev)		//give ev of parent for 1 of node
{
	if(diff<0)
	{
		cout<<"NO\n";
		exit(0);
	}
	done[root]=1;
	for(pair<int,int> i:conn[root])
	{
		if(!done[i.F])
		{
			a[root]+=dfs1(i.F,i.S);
		}
	}
	if(a[root]<b[root])
	{
		if(ev>0)
		{
			diff-=(a[root]+(b[root]-a[root])*ev)-(b[root]);
			return (a[root]-b[root])*ev;
		}
		else
		{
			return a[root]-b[root];
		}
	}
	else
	{
		if(ev>0)
		{
			return a[root]-b[root];
		}
		else
		{
			diff-=a[root]-(b[root]+(a[root]-b[root])/(-ev));
			return (a[root]-b[root])/(-ev);
		}
	}
}

signed main()
{
	fio
	cin>>n;
	a.resize(n);
	b.resize(n);
	fo(i,n)
		cin>>a[i];
	fo(i,n)
		cin>>b[i];
	diff=sum(a)-sum(b);
	fo(i,n-1)
	{
		inp(x) inp(k)
		x--;
		conn[i+1].pb(mp(x,-k));
		conn[x].pb(mp(i+1,k));
	}
	memset(done,0,sizeof(done));
	if(dfs1(0,1)<0)
		cout<<"NO\n";
	else
		cout<<"YES\n";
	printclock;
}


#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define pb push_back
#define pf pop_front
#define mp make_pair
#define mod 1000000007
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mat vector<vector<int>>
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define fo(i,n) for(int i=0;i<n;i++)
#define inp(a) int a;cin>>a;
#define inpa(a,n)vector<int> a(n);fo(i,n)cin>>a[i];
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
using namespace std;
#define int ll
#define INF 110000000000000000

void print(auto a){for(auto i:a)cerr<<i<<' ';cerr<<'\n';}
int sum(auto a){int ans=0;for(int i:a)ans+=i;return ans;}

int n;
vector<int> a,b;
vector<int> conn[100000];
bool done[100000];
map<pair<int,int>,int> cost;

int dfs1(int root,int par)
{
	done[root]=1;
	for(int i:conn[root])
	{
		if(!done[i])
		{
			a[root]+=dfs1(i,root);
			if(a[root]<-INF)
			{
				cout<<"NO\n";
				exit(0);
			}
		}
	}
	if(a[root]<b[root])
	{
		if(INF/(b[root]-a[root])<cost[mp(par,root)])
		{
			cout<<"NO\n";
			exit(0);
		}
		return (a[root]-b[root])*cost[mp(par,root)];
	}
	else
	{
		return (a[root]-b[root])/cost[mp(root,par)];
	}
}

signed main()
{
	fio
	cin>>n;
	a.resize(n);
	b.resize(n);
	fo(i,n)
		cin>>a[i];
	fo(i,n)
		cin>>b[i];
	if(sum(a)<sum(b))
	{
		cout<<"NO\n";
		return 0;
	}
	cost[mp((int)0,(int)0)]=1;
	fo(i,n-1)
	{
		inp(x) inp(k)
		x--;
		conn[i+1].pb(x);
		conn[x].pb(i+1);
		cost[mp(i+1,x)]=1;
		cost[mp(x,i+1)]=k;
	}
	memset(done,0,sizeof(done));
	if(dfs1(0,0)<0)
		cout<<"NO\n";
	else
		cout<<"YES\n";
	printclock;
}


#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define pb push_back
#define pf pop_front
#define mp make_pair
#define mod 1000000007
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mat vector<vector<int>>
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define fo(i,n) for(int i=0;i<n;i++)
#define inp(a) int a;cin>>a;
#define inpa(a,n)vector<int> a(n);fo(i,n)cin>>a[i];
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
using namespace std;
#define int ll

auto sum(auto a){auto ans=0;for(auto i:a)ans+=i;return ans;}

int n;
vector<int> a,b;
vector<pair<int,int>> conn[100000];
bool done[100000];
int diff;

int dfs1(int root,int ev)		//give ev of parent for 1 of node
{
	if(diff<0)
	{
		cout<<"NO\n";
		exit(0);
	}
	done[root]=1;
	for(pair<int,int> i:conn[root])
	{
		if(!done[i.F])
		{
			a[root]+=dfs1(i.F,i.S);
		}
	}
	if(a[root]<b[root])
	{
		if(ev>0)
		{
			if(ceil((ld)diff/(b[root]-a[root]))<ev-1)
			{
				cout<<"NO\n";
				exit(0);
			}
			diff-=(b[root]-a[root])*(ev-1);
			return (a[root]-b[root])*ev;
		}
		else
		{
			return a[root]-b[root];
		}
	}
	else
	{
		if(ev>0)
		{
			return a[root]-b[root];
		}
		else
		{
			diff-=a[root]-(b[root]+(a[root]-b[root])/(-ev));
			return (a[root]-b[root])/(-ev);
		}
	}
}

signed main()
{
	fio
	cin>>n;
	a.resize(n);
	b.resize(n);
	fo(i,n)
		cin>>a[i];
	fo(i,n)
		cin>>b[i];
	diff=sum(a)-sum(b);
	fo(i,n-1)
	{
		inp(x) inp(k)
		x--;
		conn[i+1].pb(mp(x,-k));
		conn[x].pb(mp(i+1,k));
	}
	memset(done,0,sizeof(done));
	if(dfs1(0,1)<0)
		cout<<"NO\n";
	else
		cout<<"YES\n";
	printclock;
}


#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define pb push_back
#define pf pop_front
#define mp make_pair
#define mod 1000000007
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mat vector<vector<int>>
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define fo(i,n) for(int i=0;i<n;i++)
#define inp(a) int a;cin>>a;
#define inpa(a,n)vector<int> a(n);fo(i,n)cin>>a[i];
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
using namespace std;
#define int ll

void print(auto a){for(auto i:a)cerr<<i<<' ';cerr<<'\n';}
int sum(auto a){int ans=0;for(int i:a)ans+=i;return ans;}

int n;
vector<int> a,b;
vector<int> conn[100000];
bool done[100000];
map<pair<int,int>,int> cost;

int dfs1(int root,int par)
{
	done[root]=1;
	for(int i:conn[root])
	{
		if(!done[i])
		{
			a[root]+=dfs1(i,root);
		}
	}
	if(a[root]<b[root])
	{
		return (a[root]-b[root])*cost[mp(par,root)];
	}
	else
	{
		return (a[root]-b[root])/cost[mp(root,par)];
	}
}

signed main()
{
	fio
	cin>>n;
	a.resize(n);
	b.resize(n);
	fo(i,n)
		cin>>a[i];
	fo(i,n)
		cin>>b[i];
	if(sum(a)<sum(b))
	{
		cout<<"NO\n";
		return 0;
	}
	cost[mp((int)0,(int)0)]=1;
	fo(i,n-1)
	{
		inp(x) inp(k)
		x--;
		conn[i+1].pb(x);
		conn[x].pb(i+1);
		cost[mp(i+1,x)]=1;
		cost[mp(x,i+1)]=k;
	}
	memset(done,0,sizeof(done));
	if(dfs1(0,0)<0)
		cout<<"NO\n";
	else
		cout<<"YES\n";
	printclock;
}


#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define pb push_back
#define pf pop_front
#define mp make_pair
#define mod 1000000007
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mat vector<vector<int>>
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define fo(i,n) for(int i=0;i<n;i++)
#define inp(a) int a;cin>>a;
#define inpa(a,n)vector<int> a(n);fo(i,n)cin>>a[i];
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
using namespace std;
#define int ll

auto max(auto a){auto ans=a[0];for(auto i:a)if(i>ans)ans=i;return ans;}
auto min(auto a){auto ans=a[0];for(auto i:a)if(i<ans)ans=i;return ans;}
void print(auto a){for(auto i:a)cerr<<i<<' ';cerr<<'\n';}

int n;
vector<int> a,b;
vector<pair<int,int>> conn[100000];
bool done[100000];

int dfs1(int root,int ev)		//give ev of parent for 1 of node
{
	done[root]=1;
	for(pair<int,int> i:conn[root])
	{
		if(!done[i.F])
		{
			a[root]+=dfs1(i.F,i.S);
		}
	}
	if(a[root]<b[root])
	{
		if(ev>0)
		{
			return (a[root]-b[root])*ev;
		}
		else
		{
			return a[root]-b[root];
		}
	}
	else
	{
		if(ev>0)
		{
			return a[root]-b[root];
		}
		else
		{
			return (a[root]-b[root])/ev;
		}
	}
}

signed main()
{
	fio
	cin>>n;
	a.resize(n);
	b.resize(n);
	fo(i,n)
		cin>>a[i];
	fo(i,n)
		cin>>b[i];
	fo(i,n-1)
	{
		inp(x) inp(k)
		x--;
		conn[i+1].pb(mp(x,-k));
		conn[x].pb(mp(i+1,k));
	}
	memset(done,0,sizeof(done));
	if(dfs1(0,1)<0)
		cout<<"NO\n";
	else
		cout<<"YES\n";
	printclock;
}


	#include<bits/stdc++.h>
	#define ll long long int
	#define ull unsigned long long int
	#define ld long double
	#define pb push_back
	#define pf pop_front
	#define mp make_pair
	#define mod 1000000007
	#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
	#define mat vector<vector<int>>
	#define all(x) x.begin(),x.end()
	#define F first
	#define S second
	#define fo(i,n) for(int i=0;i<n;i++)
	#define inp(a) int a;cin>>a;
	#define inpa(a,n)vector<int> a(n);fo(i,n)cin>>a[i];
	#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
	using namespace std;
	#define int ll

	auto sum(auto a){auto ans=0;for(auto i:a)ans+=i;return ans;}

	int n;
	vector<int> a,b;
	vector<pair<int,int>> conn[100000];
	bool done[100000];
	int diff;

	int dfs1(int root,int ev)		//give ev of parent for 1 of node
	{
		if(diff<0)
		{
			cout<<"NO\n";
			exit(0);
		}
		done[root]=1;
		for(pair<int,int> i:conn[root])
		{
			if(!done[i.F])
			{
				a[root]+=dfs1(i.F,i.S);
			}
		}
		if(a[root]<b[root])
		{
			if(ev>0)
			{
				if((diff+b[root]+a[root])/ev+1<b[root]-a[root])
				{
					cout<<"NO\n";
					exit(0);
				}
				diff-=(a[root]+(b[root]-a[root])*ev)-(b[root]);
				return (a[root]-b[root])*ev;
			}
			else
			{
				return a[root]-b[root];
			}
		}
		else
		{
			if(ev>0)
			{
				return a[root]-b[root];
			}
			else
			{
				diff-=a[root]-(b[root]+(a[root]-b[root])/(-ev));
				return (a[root]-b[root])/(-ev);
			}
		}
	}

	signed main()
	{
		fio
		cin>>n;
		a.resize(n);
		b.resize(n);
		fo(i,n)
			cin>>a[i];
		fo(i,n)
			cin>>b[i];
		diff=sum(a)-sum(b);
		fo(i,n-1)
		{
			inp(x) inp(k)
			x--;
			conn[i+1].pb(mp(x,-k));
			conn[x].pb(mp(i+1,k));
		}
		memset(done,0,sizeof(done));
		if(dfs1(0,1)<0)
			cout<<"NO\n";
		else
			cout<<"YES\n";
		printclock;
	}


#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int x[100005],k[100005];
int b[100005],a[100005];
int val[100005],dp[100005];
vector<vector<pair<int,int> > >adj;
bool flag=true;

bool check(int a,int b)
{
   string x=to_string(a);
   string y=to_string(b);
   if(x.length()+y.length()>18)
   {
      return true;
   }
   return false;
}

int loda_dfs(int ver)
{
   if(!flag)
      return 0;
   int sum1=0,sum2=0;
   for(auto i:adj[ver])
   {
      int z=loda_dfs(i.first);
      if(z>0)
         sum1+=z;
      else
      {
         if(check(i.second,-z))
         {
            flag=false;
            return 0;
         }
         sum2+=i.second*z;
      }
   }
   dp[ver]+=val[ver]+sum1+sum2;
   if(to_string(dp[ver]).length()>18)
      flag=false;
   return dp[ver];
}

signed main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
 #ifndef ONLINE_JUDGE
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
 #endif

// -------------------------------------Code starts here---------------------------------------------------------------------

   int n;
   cin>>n;
   adj.resize(n+1);
   for(int i=1;i<=n;i++)
              cin>>b[i];
           for(int i=1;i<=n;i++)
              cin>>a[i];

           for(int i=2;i<=n;i++)
           {
              cin>>x[i]>>k[i];
              adj[x[i]].push_back({i,k[i]});
           }
           for(int i=1;i<=n;i++)
              val[i]=b[i]-a[i];

           int z=loda_dfs(1);
           if(z<0)
           {
              cout<<"NO";
           }
           else if(!flag)
              cout<<"NO";
           else
              cout<<"YES";

        // -------------------------------------Code ends here------------------------------------------------------------------
             clock_t clk;
         	clk = clock();

            clk = clock() - clk;
         	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
         	return 0;
         }


#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int x[100005],k[100005];
int b[100005],a[100005];
int vis[100005];
int parent[100005];
int val[100005],dp[100005];
vector<vector<pair<int,int> > >adj,adj2;
vector<vector<int> >tope;
vector<int>comp,temp;
bool check(int a,int b)
{
   string x=to_string(a);
   string y=to_string(b);
   if(x.length()+y.length()>18)
   {
      return true;
   }
   return false;
}

bool flag=true;
void dfs(int ver)
{
   vis[ver]=1;
   for(auto i:adj[ver])
   {
      if(!vis[i.first])
         dfs(i.first);
   }
   comp.push_back(ver);
}

void dfs2(int ver)
{
   vis[ver]=1;
   temp.push_back(ver);
   for(auto i:tope[ver])
   {
      if(!vis[i])
         dfs2(i);
   }
}

int loda_dfs(int ver)
{
   if(!flag)
      return 0;
   int sum1=0,sum2=0;
   for(auto i:adj2[ver])
   {
      int z=loda_dfs(i.first);
      if(z>0)
         sum1+=z;
      else
      {
         if(check(i.second,-z))
         {
            flag=false;
            return 0;
         }
         sum2+=i.second*z;
      }
   }
   dp[ver]+=val[ver]+sum1+sum2;
   return dp[ver];
}

signed main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
 #ifndef ONLINE_JUDGE
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
 #endif

// -------------------------------------Code starts here---------------------------------------------------------------------

   int n;
   cin>>n;
   adj.resize(n+1);
   tope.resize(n+1);
   adj2.resize(n+1);
   for(int i=1;i<=n;i++)
      cin>>b[i];
   for(int i=1;i<=n;i++)
      cin>>a[i];

   for(int i=2;i<=n;i++)
   {
      cin>>x[i]>>k[i];
      adj[x[i]].push_back({i,k[i]});
      tope[i].push_back(x[i]);
   }
   for(int i=1;i<=n;i++)
   {
      if(vis[i]==0)
         {
            dfs(i);
         }
   }

   reverse(comp.begin(),comp.end());
   fill_n(vis,100005,0);
   vector<int>khel;
   for(auto i:comp)
   {
      if(!vis[i])
      {
         temp.clear();
         dfs2(i);
         khel.push_back(i);
         for(auto j:temp)
         {
            parent[j]=i;
            val[i]+=b[j]-a[j];
         }
      }
   }

   for(int i=1;i<=n;i++)
   {
      for(auto j:adj[i])
      {
         if(parent[i]!=parent[j.first])
            adj2[parent[i]].push_back({parent[j.first],j.second});
      }
   }

   for(auto i:khel)
   {
      int z=loda_dfs(i);
      if(z<0)
      {
         cout<<"NO";
         return 0;
      }
   }
   if(!flag)
      cout<<"NO";
   else
      cout<<"YES";

// -------------------------------------Code ends here------------------------------------------------------------------
     clock_t clk;
 	clk = clock();

    clk = clock() - clk;
 	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
 	return 0;
 }


#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int x[100005],k[100005];
int b[100005],a[100005];
int vis[100005];
int parent[100005];
int val[100005],dp[100005];
vector<vector<pair<int,int> > >adj,adj2;
vector<vector<int> >tope;
vector<int>comp,temp;
void dfs(int ver)
{
   vis[ver]=1;
   for(auto i:adj[ver])
   {
      if(!vis[i.first])
         dfs(i.first);
   }
   comp.push_back(ver);
}

void dfs2(int ver)
{
   vis[ver]=1;
   temp.push_back(ver);
   for(auto i:tope[ver])
   {
      if(!vis[i])
         dfs2(i);
   }
}

int loda_dfs(int ver)
{
   int sum1=0,sum2=0;
   for(auto i:adj2[ver])
   {
      int z=loda_dfs(i.first);
      if(z>0)
         sum1+=z;
      else
         sum2+=i.second*z;
   }
   dp[ver]+=val[ver]+sum1+sum2;
   return dp[ver];
}

signed main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
 #ifndef ONLINE_JUDGE
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
 #endif

// -------------------------------------Code starts here---------------------------------------------------------------------

   int n;
   cin>>n;
   adj.resize(n+1);
   tope.resize(n+1);
   adj2.resize(n+1);
   for(int i=1;i<=n;i++)
      cin>>b[i];
   for(int i=1;i<=n;i++)
      cin>>a[i];

   for(int i=2;i<=n;i++)
   {
      cin>>x[i]>>k[i];
      adj[x[i]].push_back({i,k[i]});
      tope[i].push_back(x[i]);
   }
   for(int i=1;i<=n;i++)
   {
      if(vis[i]==0)
         {
            dfs(i);
         }
   }

   reverse(comp.begin(),comp.end());
   fill_n(vis,100005,0);
   vector<int>khel;
   for(auto i:comp)
   {
      if(!vis[i])
      {
         temp.clear();
         dfs2(i);
         khel.push_back(i);
         for(auto j:temp)
         {
            parent[j]=i;
            val[i]+=b[j]-a[j];
         }
      }
   }

   for(int i=1;i<=n;i++)
   {
      for(auto j:adj[i])
      {
         if(parent[i]!=parent[j.first])
            adj2[parent[i]].push_back({parent[j.first],j.second});
      }
   }

   for(auto i:khel)
   {
      int z=loda_dfs(i);
      if(z<0)
      {
         cout<<"NO";
         return 0;
      }
   }
   cout<<"YES";

// -------------------------------------Code ends here------------------------------------------------------------------
     clock_t clk;
 	clk = clock();

    clk = clock() - clk;
 	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
 	return 0;
 }


//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <iterator>
#include <functional>
#include <limits>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <stack>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define trace(x) cerr << #x << ": " << x << " " << endl;

typedef int64_t ll;

#define endl '\n'
#define int ll
ll mod=1e9+7;
ll mod1=1e9+5;
ll power(ll a,ll b)
{
    if(b==0) return 1;
    else if(b%2==0)
        return power(((((a)%mod)*((a)%mod))%mod),b/2)%mod;
    else return (((a)%mod)*(power(((((a)%mod)*((a)%mod))%mod),b/2)%mod))%mod;
}
inline ll inverse(ll a,ll md) {
  a %= md;
  if (a < 0) a += md;
  ll b = md, u = 0, v = 1;
  while (a) {
    ll t = b / a;
    b -= t * a; swap(a, b);
    u -= t * v; swap(u, v);
  }
  assert(b == 1);
  if (u < 0) u += md;
  return u;
}

 //using namespace __gnu_pbds;
 //#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
//find_by_order(k)  returns iterator to kth element starting from 0;
//order_of_key(k) returns count of elements strictly smaller than k;
//erase,insert same as normal set
//mt19937 mrand(chrono::high_resolution_clock::now().time_since_epoch().count()); //for randomized solution
const int ce=1e9+7;
ll fast_mod(ll input)
{
    return input < ce ? input : input%ce;
}
int b[100001];
int a[100001];
int cost[100001];
int dp[100001];
vector<int> v[100001];
int ch=1e17+100;
void dfs(int u,int par)
{
    int sum=b[u];
    for(auto i:v[u])
        if(i==par)
            continue;
        else
        {
            dfs(i,u);
            int f=dp[i];
            int req=a[i]-dp[i];
            if(abs(req)>ch)
            {
                cout<<"NO";
                exit(0);
            }
            if(req<0)
                sum+=abs(req);
            else
                {
                    if((sum+ch+cost[i]-1)/cost[i]<=req)
                    {
                        cout<<"NO";
                        exit(0);
                    }
                    sum-=cost[i]*req;
                }
        }
    dp[u]=sum;
}
int32_t main()
{
    IOS
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    #endif

    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>b[i];
    for(int i=1;i<=n;i++)
        cin>>a[i];
    for(int i=1;i<=n-1;i++)
    {
        int u;
        cin>>u;
        v[u].push_back(i+1);
        cin>>cost[i+1];
    }
    dfs(1,0);
    if(dp[1]>=a[1])
        cout<<"YES";
    else
        cout<<"NO";

}


//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <iterator>
#include <functional>
#include <limits>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <stack>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define trace(x) cerr << #x << ": " << x << " " << endl;

typedef int64_t ll;

#define endl '\n'
#define int ll
ll mod=1e9+7;
ll mod1=1e9+5;
ll power(ll a,ll b)
{
    if(b==0) return 1;
    else if(b%2==0)
        return power(((((a)%mod)*((a)%mod))%mod),b/2)%mod;
    else return (((a)%mod)*(power(((((a)%mod)*((a)%mod))%mod),b/2)%mod))%mod;
}
inline ll inverse(ll a,ll md) {
  a %= md;
  if (a < 0) a += md;
  ll b = md, u = 0, v = 1;
  while (a) {
    ll t = b / a;
    b -= t * a; swap(a, b);
    u -= t * v; swap(u, v);
  }
  assert(b == 1);
  if (u < 0) u += md;
  return u;
}

 //using namespace __gnu_pbds;
 //#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
//find_by_order(k)  returns iterator to kth element starting from 0;
//order_of_key(k) returns count of elements strictly smaller than k;
//erase,insert same as normal set
//mt19937 mrand(chrono::high_resolution_clock::now().time_since_epoch().count()); //for randomized solution
const int ce=1e9+7;
ll fast_mod(ll input)
{
    return input < ce ? input : input%ce;
}
int b[100001];
int a[100001];
int cost[100001];
int dp[100001];
vector<int> v[100001];
void dfs(int u,int par)
{
    int sum=b[u];
    for(auto i:v[u])
        if(i==par)
            continue;
        else
        {
            dfs(i,u);
            int f=dp[i];
            int req=a[i]-dp[i];
            if(req<0)
                sum+=abs(req);
            else
                sum-=cost[i]*req;
        }
    dp[u]=sum;
}
int32_t main()
{
    IOS
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    #endif

    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>b[i];
    for(int i=1;i<=n;i++)
        cin>>a[i];
    for(int i=1;i<=n-1;i++)
    {
        int u;
        cin>>u;
        v[u].push_back(i+1);
        cin>>cost[i+1];
    }
    dfs(1,0);
    if(dp[1]>=a[1])
        cout<<"YES";
    else
        cout<<"NO";

}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N_MAX = 10 + 5;
const ll INF = 3E18;

int n, x[N_MAX];
ll a[N_MAX], b[N_MAX], k[N_MAX];

int main() {
    ios_base::sync_with_stdio(false);
    cin >> n;
    for (int i = 1; i <= n; ++i) cin >> b[i];
    for (int i = 1; i <= n; ++i) cin >> a[i];
    for (int i = 2; i <= n; ++i) cin >> x[i] >> k[i];
    for (int i = n; i > 1; --i) {
        ll c = b[i] - a[i];
        if (c < 0) c = (-INF / c) < k[i] ? -INF : c *= k[i];
        b[x[i]] = max(-INF, min(INF, b[x[i]] + c));
    }
    cout << (b[1] >= 0 ? "YES\n" : "NO\n");
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define sz(a) (int)a.size()

typedef long long ll;
typedef pair<int, int> ii;

const int N_MAX = 1e5 + 5;
const ll INF = 3e18;

int n, deg[N_MAX], vis[N_MAX];
ll a[N_MAX], b[N_MAX];
vector<ii> adj[N_MAX];
queue<int> q;
string ans = "YES";

void solve() {
    int last = -1;
    for (int i = 1; i <= n; ++i)
        if (sz(adj[i]) == 1) q.push(i), vis[i] = 1;
    while (!q.empty()) {
        int u = q.front(); q.pop();
        ll c = b[u] - a[u];
        vis[u] = 2;
        last = u;
        for (int i = 0; i < sz(adj[u]); ++i) {
            int v = adj[u][i].fi, w = adj[u][i].se;
            if (vis[v] == 2) continue;
            ll tmp = c >= 0 ? c : (INF / abs(c) < abs(w)) ? INF : c * w;
            b[v] = max(-INF, min(INF, b[v] + tmp));
            if (vis[v] == 0 && (--deg[v]) == 1) q.push(v), vis[v] == 1;
        }
    }
    if (b[last] < 0) ans = "NO";
}

int main() {
    ios_base::sync_with_stdio(false);
    cin >> n;
    for (int i = 1; i <= n; ++i) cin >> b[i];
    for (int i = 1; i <= n; ++i) cin >> a[i];
    for (int u = 2; u <= n; ++u) {
        int v, w;
        cin >> v >> w;
        adj[u].push_back({v, w}); ++deg[u];
        adj[v].push_back({u, 1}); ++deg[v];
    }
    solve();
    cout << ans << "\n";
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N_MAX = 1E5 + 5;
const ll INF = 3E18;

int n, a[N_MAX], b[N_MAX], x[N_MAX], k[N_MAX];

int main() {
    ios_base::sync_with_stdio(false);
    cin >> n;
    for (int i = 1; i <= n; ++i) cin >> b[i];
    for (int i = 1; i <= n; ++i) cin >> a[i];
    for (int i = 2; i <= n; ++i) cin >> x[i] >> k[i];
    for (int i = n; i > 1; --i) {
        ll c = b[i] - a[i];
        if (c < 0) c = (-INF / c) < k[i] ? -INF : c *= k[i];
        b[x[i]] = max(-INF, min(INF, b[x[i]] + c));
    }
    cout << (b[1] >= 0 ? "YES\n" : "NO\n");
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N_MAX = 1E5 + 5;
const ll INF = 3E18;

int n, x[N_MAX];
ll a[N_MAX], b[N_MAX], k[N_MAX];

int main() {
    ios_base::sync_with_stdio(false);
    cin >> n;
    for (int i = 1; i <= n; ++i) cin >> b[i];
    for (int i = 1; i <= n; ++i) cin >> a[i];
    for (int i = 2; i <= n; ++i) cin >> x[i] >> k[i];
    for (int i = n; i > 1; --i) {
        ll c = b[i] - a[i];
        if (c < 0) c = (-INF / c) < k[i] ? -INF : c *= k[i];
        b[x[i]] = max(-INF, min(INF, b[x[i]] + c));
    }
    cout << (b[1] >= 0 ? "YES\n" : "NO\n");
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n;
	cin >> n;
	vector<long long> a(n),b(n);
	for(int i=0;i<n;i++) cin >> b[i];
	for(int i=0;i<n;i++) cin >> a[i];
	for(int i=0;i<n;i++) b[i]-=a[i];
	vector<vector<pair<int,long long>>> ad(n);
	for(int i=1;i<n;i++){
		int p;
		long long k;
		cin >> p >> k;
		p--;
		ad[p].push_back(make_pair(i,k));
		ad[i].push_back(make_pair(p,1LL));
	}

	long long sum=0;
	for(int i=0;i<n;i++) sum+=b[i];
	if(sum<0){
		cout << "NO\n";
		return 0;
	}
	function<long long(int,int)> dfs=[&](int cur,int par){
		for(auto p0:ad[cur]){
			int ch=p0.first;
			if(ch==par) continue;
			long long diff=dfs(ch,cur);
			if(diff>=0) b[cur]+=diff;
			else{
				if(sum/p0.second<(-diff)){
					cout << "NO\n";
					exit(0);
				}
				sum+=diff*p0.second;
				b[cur]+=diff*p0.second;
				if(sum<0){
					cout << "NO\n";
					exit(0);
				}
			}
		}
		//cout << " " << cur << " " << b[cur] << "\n";
		return b[cur];
	};
	long long res=dfs(0,-1);
	if(res>=0) cout << "YES\n";
	else cout << "NO\n";
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n;
	cin >> n;
	vector<long long> a(n),b(n);
	for(int i=0;i<n;i++) cin >> b[i];
	for(int i=0;i<n;i++) cin >> a[i];
	for(int i=0;i<n;i++) b[i]-=a[i];
	vector<vector<pair<int,long long>>> ad(n);
	for(int i=1;i<n;i++){
		int p;
		long long k;
		cin >> p >> k;
		p--;
		ad[p].push_back(make_pair(i,k));
		ad[i].push_back(make_pair(p,1LL));
	}

	function<long long(int,int)> dfs=[&](int cur,int par){
		for(auto p0:ad[cur]){
			int ch=p0.first;
			if(ch==par) continue;
			long long diff=dfs(ch,cur);
			if(diff>=0) b[cur]+=diff;
			else b[cur]+=diff*p0.second;
		}
		//cout << " " << cur << " " << b[cur] << "\n";
		return b[cur];
	};
	long long res=dfs(0,-1);
	if(res>=0) cout << "YES\n";
	else cout << "NO\n";
	return 0;
}


//#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <bits/stdc++.h>
using namespace std;

#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;

#define boost ios::sync_with_stdio(0); cin.tie(0)

#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

typedef long long ll;
typedef double ld;
typedef pair<ll, ll> pii;

const int N = 1e5 + 5;
const ll INF = 2e18;

/***************************************************************************/

ll multiply(ll a, ll b) {
	if(a <= INF/b) {
		return a * b;
	}
	else return INF;
}

ll A[N], B[N];
pii par[N];
vector<int> adj[N];

void dfs(int v, int p) {
	for(auto u : adj[v]) {
		if(u == p) continue;
		dfs(u, v);
	}
	if(v == 1) return;
	if(B[v] >= A[v]) {
		B[p] = min(B[p]+B[v]-A[v], INF);
	}
	else {
		B[p] = max(B[p]-multiply(A[v]-B[v], par[v].se), -INF);
	}
}

int main() {

	boost;
	int n; cin>>n;
	for(int i=1; i<=n; i++) {
		cin>>B[i];
	}
	for(int i=1; i<=n; i++) {
		cin>>A[i];
	}
	for(int i=2; i<=n; i++) {
		cin>>par[i].fi>>par[i].se;
		adj[par[i].fi].pb(i);
	}
	dfs(1, 0);
	if(B[1] >= A[1]) cout<<"YES\n";
	else cout<<"NO\n";
	return 0;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#define SF scanf
#define PF printf
#define MAXN 100010
#define INF 110000000000000000
using namespace std;
typedef long long ll;
vector<int> a[MAXN];
ll k[MAXN],A[MAXN],B[MAXN];
int fa,val;
ll dp[MAXN];
bool check(ll x,ll y){
	double xx=1.0*x;
	double yy=1.0*y;
	if(xx*yy<-INF)
		return 1;
	return 0;
}
void dfs(int x){
	dp[x]=B[x]-A[x];
	for(int i=0;i<int(a[x].size());i++){
		dfs(a[x][i]);
		dp[x]+=dp[a[x][i]];
	}
	if(dp[x]<0){
		if(check(dp[x],k[x])){
			PF("NO");
			exit(0);
		}
		dp[x]*=k[x];
	}
}
int n;
int main(){
	SF("%d",&n);
	for(int i=1;i<=n;i++)
		SF("%d",&B[i]);
	for(int i=1;i<=n;i++)
		SF("%d",&A[i]);
	for(int i=2;i<=n;i++){
		SF("%d%d",&fa,&k[i]);
		a[fa].push_back(i);
	}
	k[1]=1;
	dfs(1);
	if(dp[1]>=0)
		PF("YES");
	else
		PF("NO");
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#define SF scanf
#define PF printf
#define MAXN 100010
#define INF 1000000000000000000ll
#define INTMAX 10000000000ll
using namespace std;
typedef long long ll;
vector<int> a[MAXN];
ll k[MAXN],A[MAXN],B[MAXN];
int fa,val;
ll dp[MAXN];
void dfs(int x){
	dp[x]=B[x]-A[x];
	for(int i=0;i<int(a[x].size());i++){
		dfs(a[x][i]);
		dp[x]+=dp[a[x][i]];
	}
	if(dp[x]<-INTMAX||k[x]>INTMAX){
		PF("NO");
		exit(0);
	}
	if(dp[x]<0)
		dp[x]*=k[x];
	if(dp[x]<-INF){
		PF("NO");
		exit(0);
	}
}
int n;
int main(){
	SF("%d",&n);
	for(int i=1;i<=n;i++)
		SF("%d",&B[i]);
	for(int i=1;i<=n;i++)
		SF("%d",&A[i]);
	for(int i=2;i<=n;i++){
		SF("%d%d",&fa,&k[i]);
		a[fa].push_back(i);
	}
	k[1]=1;
	dfs(1);
	if(dp[1]>=0)
		PF("YES");
	else
		PF("NO");
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#define SF scanf
#define PF printf
#define MAXN 100010
#define INF 110000000000000000
using namespace std;
typedef long long ll;
vector<int> a[MAXN];
ll k[MAXN],A[MAXN],B[MAXN];
int fa,val;
ll dp[MAXN];
bool check(ll x,ll y){
	double xx=1.0*x;
	double yy=1.0*y;
	if(xx*yy<-INF)
		return 1;
	return 0;
}
void dfs(int x){
	dp[x]=B[x]-A[x];
	for(int i=0;i<int(a[x].size());i++){
		dfs(a[x][i]);
		dp[x]+=dp[a[x][i]];
		if(check(dp[x],k[x])){
			PF("NO");
			exit(0);
		}
	}
	if(dp[x]<0){
		if(check(dp[x],k[x])){
			PF("NO");
			exit(0);
		}
		dp[x]*=k[x];
	}
}
int n;
int main(){
	SF("%d",&n);
	for(int i=1;i<=n;i++)
		SF("%d",&B[i]);
	for(int i=1;i<=n;i++)
		SF("%d",&A[i]);
	for(int i=2;i<=n;i++){
		SF("%d%d",&fa,&k[i]);
		a[fa].push_back(i);
	}
	k[1]=1;
	dfs(1);
	if(dp[1]>=0)
		PF("YES");
	else
		PF("NO");
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#define SF scanf
#define PF printf
#define MAXN 100010
#define INF 1000000000000000000.0
using namespace std;
typedef long long ll;
vector<int> a[MAXN];
ll k[MAXN],A[MAXN],B[MAXN];
int fa,val;
ll dp[MAXN];
bool check(ll x,ll y){
	double xx=1.0*x;
	double yy=1.0*y;
	if(xx*yy>INF)
		return 1;
	return 0;
}
void dfs(int x){
	dp[x]=B[x]-A[x];
	for(int i=0;i<int(a[x].size());i++){
		dfs(a[x][i]);
		dp[x]+=dp[a[x][i]];
	}
	if(dp[x]<0){
		if(check(dp[x],k[x])){
			PF("NO");
			exit(0);
		}
		dp[x]*=k[x];
	}
}
int n;
int main(){
	SF("%d",&n);
	for(int i=1;i<=n;i++)
		SF("%d",&B[i]);
	for(int i=1;i<=n;i++)
		SF("%d",&A[i]);
	for(int i=2;i<=n;i++){
		SF("%d%d",&fa,&k[i]);
		a[fa].push_back(i);
	}
	k[1]=1;
	dfs(1);
	if(dp[1]>=0)
		PF("YES");
	else
		PF("NO");
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#define SF scanf
#define PF printf
#define MAXN 100010
using namespace std;
vector<int> a[MAXN];
int k[MAXN],A[MAXN],B[MAXN];
int fa,val;
int dp[MAXN];
void dfs(int x){
	dp[x]=B[x]-A[x];
	for(int i=0;i<int(a[x].size());i++){
		dfs(a[x][i]);
		dp[x]+=dp[a[x][i]];
	}
	if(dp[x]>0)
		dp[x]/=k[x];
	//PF("[%d]\n",dp[x]);
}
int n;
int main(){
	SF("%d",&n);
	for(int i=1;i<=n;i++)
		SF("%d",&B[i]);
	for(int i=1;i<=n;i++)
		SF("%d",&A[i]);
	for(int i=2;i<=n;i++){
		SF("%d%d",&fa,&k[i]);
		a[fa].push_back(i);
	}
	dfs(1);
	if(dp[1]>=0)
		PF("YES");
	else
		PF("NO");
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#define SF scanf
#define PF printf
#define MAXN 100010
#define INF 1000000000000000000ll
#define INTMAX 100000000ll
using namespace std;
typedef long long ll;
vector<int> a[MAXN];
ll k[MAXN],A[MAXN],B[MAXN];
int fa,val;
ll dp[MAXN];
void dfs(int x){
	dp[x]=B[x]-A[x];
	for(int i=0;i<int(a[x].size());i++){
		dfs(a[x][i]);
		dp[x]+=dp[a[x][i]];
	}
	if(dp[x]<-INTMAX&&k[x]>INTMAX){
		PF("NO");
		exit(0);
	}
	if(dp[x]<0)
		dp[x]*=k[x];
	if(dp[x]<-INF){
		PF("NO");
		exit(0);
	}
}
int n;
int main(){
	SF("%d",&n);
	for(int i=1;i<=n;i++)
		SF("%d",&B[i]);
	for(int i=1;i<=n;i++)
		SF("%d",&A[i]);
	for(int i=2;i<=n;i++){
		SF("%d%d",&fa,&k[i]);
		a[fa].push_back(i);
	}
	k[1]=1;
	dfs(1);
	if(dp[1]>=0)
		PF("YES");
	else
		PF("NO");
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#define SF scanf
#define PF printf
#define MAXN 100010
#define INF 110000000000000000
using namespace std;
typedef long long ll;
vector<int> a[MAXN];
ll k[MAXN],A[MAXN],B[MAXN];
int fa,val;
ll dp[MAXN];
bool check(ll x,ll y){
	double xx=1.0*x;
	double yy=1.0*y;
	if(xx*yy<-INF)
		return 1;
	return 0;
}
void dfs(int x){
	dp[x]=B[x]-A[x];
	for(int i=0;i<int(a[x].size());i++){
		dfs(a[x][i]);
		dp[x]+=dp[a[x][i]];
		if(check(dp[x],k[x])){
			PF("NO");
			exit(0);
		}
	}
	if(dp[x]<0){
		if(check(dp[x],k[x])){
			PF("NO");
			exit(0);
		}
		dp[x]*=k[x];
	}
}
int n;
int main(){
	SF("%d",&n);
	for(int i=1;i<=n;i++)
		SF("%lld",&B[i]);
	for(int i=1;i<=n;i++)
		SF("%lld",&A[i]);
	for(int i=2;i<=n;i++){
		SF("%d%lld",&fa,&k[i]);
		a[fa].push_back(i);
	}
	k[1]=1;
	dfs(1);
	if(dp[1]>=0)
		PF("YES");
	else
		PF("NO");
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#define SF scanf
#define PF printf
#define MAXN 100010
#define INF 1000000000000000000ll
using namespace std;
typedef long long ll;
vector<int> a[MAXN];
ll k[MAXN],A[MAXN],B[MAXN];
int fa,val;
ll dp[MAXN];
void dfs(int x){
	dp[x]=B[x]-A[x];
	for(int i=0;i<int(a[x].size());i++){
		dfs(a[x][i]);
		dp[x]+=dp[a[x][i]];
	}
	if(dp[x]<0)
		dp[x]*=k[x];
	if(dp[x]<-INF){
		PF("NO");
		exit(0);
	}
}
int n;
int main(){
	SF("%d",&n);
	for(int i=1;i<=n;i++)
		SF("%d",&B[i]);
	for(int i=1;i<=n;i++)
		SF("%d",&A[i]);
	for(int i=2;i<=n;i++){
		SF("%d%d",&fa,&k[i]);
		a[fa].push_back(i);
	}
	k[1]=1;
	dfs(1);
	if(dp[1]>=0)
		PF("YES");
	else
		PF("NO");
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#define SF scanf
#define PF printf
#define MAXN 100010
#define INF 1000000000000000000ll
#define INTMAX 1000000ll
using namespace std;
typedef long long ll;
vector<int> a[MAXN];
ll k[MAXN],A[MAXN],B[MAXN];
int fa,val;
ll dp[MAXN];
void dfs(int x){
	dp[x]=B[x]-A[x];
	for(int i=0;i<int(a[x].size());i++){
		dfs(a[x][i]);
		dp[x]+=dp[a[x][i]];
	}
	if(dp[x]<0){
		if((dp[x]/INTMAX)*(k[x]/INTMAX)>INTMAX){
			PF("NO");
			exit(0);
		}
		dp[x]*=k[x];
	}
}
int n;
int main(){
	SF("%d",&n);
	for(int i=1;i<=n;i++)
		SF("%d",&B[i]);
	for(int i=1;i<=n;i++)
		SF("%d",&A[i]);
	for(int i=2;i<=n;i++){
		SF("%d%d",&fa,&k[i]);
		a[fa].push_back(i);
	}
	k[1]=1;
	dfs(1);
	if(dp[1]>=0)
		PF("YES");
	else
		PF("NO");
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#define SF scanf
#define PF printf
#define MAXN 100010
#define INF 1000000000000000000ll
#define INTMAX 100000000000ll
using namespace std;
typedef long long ll;
vector<int> a[MAXN];
ll k[MAXN],A[MAXN],B[MAXN];
int fa,val;
ll dp[MAXN];
void dfs(int x){
	dp[x]=B[x]-A[x];
	for(int i=0;i<int(a[x].size());i++){
		dfs(a[x][i]);
		dp[x]+=dp[a[x][i]];
	}
	if(dp[x]<-INTMAX||k[x]>INTMAX){
		PF("NO");
		exit(0);
	}
	if(dp[x]<0)
		dp[x]*=k[x];
	if(dp[x]<-INF){
		PF("NO");
		exit(0);
	}
}
int n;
int main(){
	SF("%d",&n);
	for(int i=1;i<=n;i++)
		SF("%d",&B[i]);
	for(int i=1;i<=n;i++)
		SF("%d",&A[i]);
	for(int i=2;i<=n;i++){
		SF("%d%d",&fa,&k[i]);
		a[fa].push_back(i);
	}
	k[1]=1;
	dfs(1);
	if(dp[1]>=0)
		PF("YES");
	else
		PF("NO");
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#define SF scanf
#define PF printf
#define MAXN 100010
#define INF 10000000000000000.0
using namespace std;
typedef long long ll;
vector<int> a[MAXN];
ll k[MAXN],A[MAXN],B[MAXN];
int fa,val;
ll dp[MAXN];
bool check(ll x,ll y){
	double xx=1.0*x;
	double yy=1.0*y;
	if(xx*yy<-INF)
		return 1;
	return 0;
}
void dfs(int x){
	dp[x]=B[x]-A[x];
	for(int i=0;i<int(a[x].size());i++){
		dfs(a[x][i]);
		dp[x]+=dp[a[x][i]];
	}
	if(dp[x]<0){
		if(check(dp[x],k[x])){
			PF("NO");
			exit(0);
		}
		dp[x]*=k[x];
	}
}
int n;
int main(){
	SF("%d",&n);
	for(int i=1;i<=n;i++)
		SF("%d",&B[i]);
	for(int i=1;i<=n;i++)
		SF("%d",&A[i]);
	for(int i=2;i<=n;i++){
		SF("%d%d",&fa,&k[i]);
		a[fa].push_back(i);
	}
	k[1]=1;
	dfs(1);
	if(dp[1]>=0)
		PF("YES");
	else
		PF("NO");
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#define SF scanf
#define PF printf
#define MAXN 100010
#define INF 1000000000000000000.0
using namespace std;
typedef long long ll;
vector<int> a[MAXN];
ll k[MAXN],A[MAXN],B[MAXN];
int fa,val;
ll dp[MAXN];
bool check(ll x,ll y){
	double xx=1.0*x;
	double yy=1.0*y;
	if(xx*yy<-INF)
		return 1;
	return 0;
}
void dfs(int x){
	dp[x]=B[x]-A[x];
	for(int i=0;i<int(a[x].size());i++){
		dfs(a[x][i]);
		dp[x]+=dp[a[x][i]];
	}
	if(dp[x]<0){
		if(check(dp[x],k[x])){
			PF("NO");
			exit(0);
		}
		dp[x]*=k[x];
	}
}
int n;
int main(){
	SF("%d",&n);
	for(int i=1;i<=n;i++)
		SF("%d",&B[i]);
	for(int i=1;i<=n;i++)
		SF("%d",&A[i]);
	for(int i=2;i<=n;i++){
		SF("%d%d",&fa,&k[i]);
		a[fa].push_back(i);
	}
	k[1]=1;
	dfs(1);
	if(dp[1]>=0)
		PF("YES");
	else
		PF("NO");
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#define SF scanf
#define PF printf
#define MAXN 100010
using namespace std;
vector<int> a[MAXN];
int k[MAXN],A[MAXN],B[MAXN];
int fa,val;
int dp[MAXN];
void dfs(int x){
	dp[x]=B[x]-A[x];
	for(int i=0;i<int(a[x].size());i++){
		dfs(a[x][i]);
		dp[x]+=dp[a[x][i]];
	}
	if(dp[x]>0)
		dp[x]/=k[x];
}
int n;
int main(){
	SF("%d",&n);
	for(int i=1;i<=n;i++)
		SF("%d",&A[i]);
	for(int i=1;i<=n;i++)
		SF("%d",&B[i]);
	for(int i=2;i<=n;i++){
		SF("%d%d",&fa,&k[i]);
		a[fa].push_back(i);
	}
	dfs(1);
	if(dp[1]>=0)
		PF("YES");
	else
		PF("NO");
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#define SF scanf
#define PF printf
#define MAXN 100010
using namespace std;
vector<int> a[MAXN];
int k[MAXN],A[MAXN],B[MAXN];
int fa,val;
int dp[MAXN];
void dfs(int x){
	dp[x]=B[x]-A[x];
	for(int i=0;i<int(a[x].size());i++){
		dfs(a[x][i]);
		dp[x]+=dp[a[x][i]];
	}
	if(dp[x]<0)
		dp[x]*=k[x];
}
int n;
int main(){
	SF("%d",&n);
	for(int i=1;i<=n;i++)
		SF("%d",&B[i]);
	for(int i=1;i<=n;i++)
		SF("%d",&A[i]);
	for(int i=2;i<=n;i++){
		SF("%d%d",&fa,&k[i]);
		a[fa].push_back(i);
	}
	k[1]=1;
	dfs(1);
	if(dp[1]>=0)
		PF("YES");
	else
		PF("NO");
}


#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < ll , ll >
#define F first
#define S second
#define int long long int
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define err(A) cout << #A << " = " << (A) << endl
using namespace std;

const int N=1e5+100;

vector <int> g[N];
ll par[N];
ll a[N];

ll b[N];

ll dfs(ll v,ll p){
    //cout << v << " " << p << endl;
    for (int i=0;i<g[v].size();i++){
        ll u=g[v][i];
        if (u!=p){
            dfs(u,v);
        }
    }
    for (int i=0;i<g[v].size();i++){
        ll u=g[v][i];
        if (u!=p){
            if (a[u]<b[u]){
                a[v]-=(b[u]-a[u])*par[u];

                a[u]=b[u];
            }
        }
    }
    if (v==1){
        return 0;
    }
   // cout << " elrgn " << v << " " << p << " " << a[v] << endl;
    if (a[v]>b[v]){
        ll z=a[v]-b[v];

        a[p]+=z;
        a[v]-=z;
    }
    //cout << v << " " << p << " " << a[v] << " " << a[p] << endl;
}
int32_t main(){
    ll n;
    cin >> n;
    for (int i=1;i<=n;i++){
        cin >> a[i];
    }
    for (int i=1;i<=n;i++){
        cin >> b[i];
    }
    for (int i=2;i<=n;i++){
        ll u,k;
        cin >> u >> k;
        g[u].pb(i);
        par[i]=k;
    }
    dfs(1,-1);
    if (a[1]>=  b[1]){
        cout << "YES";
    }
    else{
        cout << "NO";
    }
}


#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < ll , ll >
#define F first
#define S second
#define int long long int
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define err(A) cout << #A << " = " << (A) << endl
using namespace std;

const int N=1e5+100;

vector <int> g[N];
ll par[N];
ll a[N];

ll b[N];
ll inf=(ll)1e18;
ll p1=0;
ll dfs(ll v,ll p){
    //cout << v << " " << p << endl;
    for (int i=0;i<g[v].size();i++){
        ll u=g[v][i];
        if (u!=p){
            dfs(u,v);
        }
    }
    for (int i=0;i<g[v].size();i++){
        ll u=g[v][i];
        if (u!=p){
            if (a[u]<b[u]){
                if (inf/par[u]<par[u]){
                    p1=1;
                }
                a[v]-=(b[u]-a[u])*par[u];

                a[u]=b[u];
            }
        }
    }
    if (v==1){
        return 0;
    }
   // cout << " elrgn " << v << " " << p << " " << a[v] << endl;
    if (a[v]>b[v]){
        ll z=a[v]-b[v];

        a[p]+=z;
        a[v]-=z;
    }
    //cout << v << " " << p << " " << a[v] << " " << a[p] << endl;
}
int32_t main(){
    ll n;
    cin >> n;
    for (int i=1;i<=n;i++){
        cin >> a[i];
    }
    for (int i=1;i<=n;i++){
        cin >> b[i];
    }
    for (int i=2;i<=n;i++){
        ll u,k;
        cin >> u >> k;
        g[u].pb(i);
        par[i]=k;
    }
    dfs(1,-1);
    if (a[1]>=b[1]){
        cout << "YES";
    }
    else{
        cout << "NO";
    }
}


#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < ll , ll >
#define F first
#define S second
#define int long long int
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define err(A) cout << #A << " = " << (A) << endl
using namespace std;

const int N=1e5+100;

vector <int> g[N];
ll par[N];
ll a[N];

ll b[N];

ll dfs(ll v,ll p){
    //cout << v << " " << p << endl;
    for (int i=0;i<g[v].size();i++){
        ll u=g[v][i];
        if (u!=p){
            dfs(u,v);
        }
    }
    for (int i=0;i<g[v].size();i++){
        ll u=g[v][i];
        if (u!=p){
            if (a[u]<b[u]){
                a[v]-=b[u]-a[u];
                a[u]=b[u];
            }
        }
    }
    if (v==1){
        return 0;
    }
   // cout << " elrgn " << v << " " << p << " " << a[v] << endl;
    if (a[v]>b[v]){
        ll z=a[v]-b[v];
        z/=par[v];
        a[p]+=z;
        a[v]-=z*par[v];
    }
    //cout << v << " " << p << " " << a[v] << endl;
}
int32_t main(){
    ll n;
    cin >> n;
    for (int i=1;i<=n;i++){
        cin >> b[i];
    }
    for (int i=1;i<=n;i++){
        cin >> a[i];
    }
    for (int i=2;i<=n;i++){
        ll u,k;
        cin >> u >> k;
        g[u].pb(i);
        par[i]=k;
    }
    dfs(1,-1);
    if (a[1]>=b[1]){
        cout << "YES";
    }
    else{
        cout << "NO";
    }
}


#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < ll , ll >
#define F first
#define S second
#define int long long int
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define err(A) cout << #A << " = " << (A) << endl
using namespace std;

const int N=1e5+100;

vector <int> g[N];
ll par[N];
ll a[N];

ll b[N];
ll inf=(ll)1e17;
ll p1=0;
ll dfs(ll v,ll p){
    //cout << v << " " << p << endl;
    for (int i=0;i<g[v].size();i++){
        ll u=g[v][i];
        if (u!=p){
            dfs(u,v);
        }
    }
    for (int i=0;i<g[v].size();i++){
        ll u=g[v][i];
        if (u!=p){
            if (a[u]<b[u]){
                if (inf/par[u]<par[u]){
                    p1=1;
                }
                a[v]-=(b[u]-a[u])*par[u];
                if (a[v]<-inf){
                    p1=1;
                }

                a[u]=b[u];
            }
        }
    }
    if (v==1){
        return 0;
    }
   // cout << " elrgn " << v << " " << p << " " << a[v] << endl;
    if (a[v]>b[v]){
        ll z=a[v]-b[v];

        a[p]+=z;
        a[v]-=z;
    }
    //cout << v << " " << p << " " << a[v] << " " << a[p] << endl;
}
int32_t main(){
    ll n;
    cin >> n;
    for (int i=1;i<=n;i++){
        cin >> a[i];
    }
    for (int i=1;i<=n;i++){
        cin >> b[i];
    }
    for (int i=2;i<=n;i++){
        ll u,k;
        cin >> u >> k;
        g[u].pb(i);
        par[i]=k;
    }
    dfs(1,-1);
    if (p1==1){
        cout << "NO";
        return 0;
    }
    if (a[1]>=b[1]){
        cout << "YES";
    }
    else{
        cout << "NO";
    }
}


#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < ll , ll >
#define F first
#define S second
#define int long long int
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define err(A) cout << #A << " = " << (A) << endl
using namespace std;

const int N=1e5+100;

vector <int> g[N];
ll par[N];
ll a[N];

ll b[N];
ll inf=(ll)1e18;
ll p1=0;
ll dfs(ll v,ll p){
    //cout << v << " " << p << endl;
    for (int i=0;i<g[v].size();i++){
        ll u=g[v][i];
        if (u!=p){
            dfs(u,v);
        }
    }
    for (int i=0;i<g[v].size();i++){
        ll u=g[v][i];
        if (u!=p){
            if (a[u]<b[u]){
                if (inf/par[u]<par[u]){
                    p1=1;
                }
                a[v]-=(b[u]-a[u])*par[u];

                a[u]=b[u];
            }
        }
    }
    if (v==1){
        return 0;
    }
   // cout << " elrgn " << v << " " << p << " " << a[v] << endl;
    if (a[v]>b[v]){
        ll z=a[v]-b[v];

        a[p]+=z;
        a[v]-=z;
    }
    //cout << v << " " << p << " " << a[v] << " " << a[p] << endl;
}
int32_t main(){
    ll n;
    cin >> n;
    for (int i=1;i<=n;i++){
        cin >> a[i];
    }
    for (int i=1;i<=n;i++){
        cin >> b[i];
    }
    for (int i=2;i<=n;i++){
        ll u,k;
        cin >> u >> k;
        g[u].pb(i);
        par[i]=k;
    }
    dfs(1,-1);
    if (p1==1){
        cout << "NO";
        return 0;
    }
    if (a[1]>=b[1]){
        cout << "YES";
    }
    else{
        cout << "NO";
    }
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#define MAXN 100000
#define INF 1000000000000000000LL
using namespace std;
typedef long long LL;
struct node
{
	int to;
	LL k;
	node *nxt;
}edges[MAXN+5];
node *ncnt=&edges[0],*Adj[MAXN+5];
LL a[MAXN+5],b[MAXN+5];
LL dp[MAXN+5];
void AddEdge(int u,int v,LL w)
{
	node *p=++ncnt;
	p->to=v;
	p->k=w;
	p->nxt=Adj[u];
	Adj[u]=p;
}
void DFS(int u)
{
	dp[u]=b[u]-a[u];
	for(node *p=Adj[u];p!=NULL;p=p->nxt)
	{
		int v=p->to,w=p->k;
		DFS(v);
		if(dp[v]<0)
		{
			if(-dp[v]<INF/w&&-(dp[u]+1LL*dp[v]*w)<INF)
				dp[u]+=1LL*dp[v]*w;
			else
				dp[u]=-INF;
		}
		else
			dp[u]+=dp[v];
	}
}
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%lld",&b[i]);
	for(int i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	int x;
	LL k;
	for(int i=2;i<=n;i++)
	{
		scanf("%d %lld",&x,&k);
		AddEdge(x,i,k);
	}
	DFS(1);
	if(dp[1]<0)
		printf("NO\n");
	else
		printf("YES\n");
	return 0;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#define MAXN 100000
#define INF 1000000000000000000LL
using namespace std;
typedef long long LL;
struct node
{
	int to;
	LL k;
	node *nxt;
}edges[MAXN+5];
node *ncnt=&edges[0],*Adj[MAXN+5];
LL a[MAXN+5],b[MAXN+5];
LL dp[MAXN+5];
void AddEdge(int u,int v,LL w)
{
	node *p=++ncnt;
	p->to=v;
	p->k=w;
	p->nxt=Adj[u];
	Adj[u]=p;
}
void DFS(int u)
{
	dp[u]=b[u]-a[u];
	for(node *p=Adj[u];p!=NULL;p=p->nxt)
	{
		int v=p->to,w=p->k;
		DFS(v);
		if(dp[v]<0)
		{
			if(-dp[v]<INF/w&&-(dp[u]+1LL*dp[v]*w)<INF)
				dp[u]+=1LL*dp[v]*w;
			else
				dp[u]=-INF;
		}
		else
			dp[u]+=dp[v];
	}
}
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%lld",&b[i]);
	for(int i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	int x;
	LL k;
	for(int i=2;i<=n;i++)
	{
		scanf("%d %lld",&x,&k);
		AddEdge(x,i,k);
	}
	DFS(1);
	if(dp[1]<0)
		printf("NO\n");
	else
		printf("YES\n");
}


#include <stdio.h>
#include <vector>
using namespace std;
using ll = long long;
bool vis[100005];
vector<int> G[100005];
ll a[100005];
ll b[100005];
ll c[100005];
ll k[100005];
void dfs(int u) {
	for (int v : G[u]) {
		if (not vis[v]) {
			vis[v] = true;
			dfs(v);
			if (c[v] > a[v]) {
				c[u] += c[v] - a[v];
				c[v] = a[v];
			} else {
				c[u] -= k[v] * (a[v] - c[v]);
				c[v] = a[v];
			}
		}
	}
}
int main(int argc, const char *argv[])
{
	int n;
	scanf("%d",&n);
	for (int i = 1; i <= n; i++) scanf("%lld",&b[i]);
	for (int i = 1; i <= n; i++) c[i] = b[i];
	for (int i = 1; i <= n; i++) scanf("%lld",&a[i]);
	for (int i = 2; i <= n; i++) {
		int x;
		scanf("%d%lld",&x,&k[i]);
		G[x].push_back(i);
		G[i].push_back(x);
	}
	vis[1] = true;
	dfs(1);
	if (c[1] == a[1]) printf("YES\n");
	else printf("NO\n");
	return 0;
}


#include <stdio.h>
#include <stdint.h>
#include <vector>
using namespace std;
using ll = long long;
bool vis[100005];
vector<int> G[100005];
ll a[100005];
ll b[100005];
double c[100005];
ll k[100005];
void dfs(int u) {
	for (int v : G[u]) {
		if (not vis[v]) {
			vis[v] = true;
			dfs(v);
			if (c[v] > (double)a[v]) {
				c[u] += c[v] - (double)a[v];
				c[v] = (double)a[v];
			} else {
				c[u] -= (double)k[v] * ((double)a[v] - c[v]);
				c[v] = (double)a[v];
			}
		}
	}
}
int main(int argc, const char *argv[])
{
	int n;
	scanf("%d",&n);
	for (int i = 1; i <= n; i++) scanf("%lld",&b[i]);
	for (int i = 1; i <= n; i++) c[i] = b[i];
	for (int i = 1; i <= n; i++) scanf("%lld",&a[i]);
	for (int i = 2; i <= n; i++) {
		int x;
		scanf("%d%lld",&x,&k[i]);
		G[x].push_back(i);
		G[i].push_back(x);
	}
	vis[1] = true;
	dfs(1);
	if (c[1] >= (double)a[1]) printf("YES\n");
	else printf("NO\n");
	return 0;
}


#include <stdio.h>
#include <vector>
using namespace std;
using ll = long long;
bool vis[100005];
vector<int> G[100005];
ll a[100005];
ll b[100005];
ll c[100005];
ll k[100005];
void dfs(int u) {
	for (int v : G[u]) {
		if (not vis[v]) {
			vis[v] = true;
			dfs(v);
			if (c[v] > a[v]) {
				c[u] += c[v] - a[v];
				c[v] = a[v];
			} else {
				c[u] -= k[v] * (a[v] - c[v]);
				c[v] = a[v];
			}
		}
	}
}
int main(int argc, const char *argv[])
{
	int n;
	scanf("%d",&n);
	for (int i = 1; i <= n; i++) scanf("%lld",&b[i]);
	for (int i = 1; i <= n; i++) c[i] = b[i];
	for (int i = 1; i <= n; i++) scanf("%lld",&a[i]);
	for (int i = 2; i <= n; i++) {
		int x;
		scanf("%d%lld",&x,&k[i]);
		G[x].push_back(i);
		G[i].push_back(x);
	}
	vis[1] = true;
	dfs(1);
	if (c[1] >= a[1]) printf("YES\n");
	else printf("NO\n");
	return 0;
}


#include <iostream>
#include <vector>
#define int long long int
using namespace std;

const int maxN = 1e5 + 326;
int pa[maxN], wei[maxN], has[maxN], need[maxN], N, isLeaf[maxN], stillneed[maxN];
bool isViable[maxN];
vector<int> chi[maxN];

void dfs(int u = 0){
	for(int v : chi[u]){
		dfs(v);
		if(!isViable[v]){
			isViable[u] = false;
			return;
		}
		if(stillneed[v]){
			//cout << "YES: " << v << endl;
			if(stillneed[v] >= ((int)1e17 + has[u] - need[u] + wei[v] - 1) / wei[v]){
				isViable[u] = false;
				//cout << u << " not viable " << endl;
				return;
			}
			has[u] -= stillneed[v] * wei[v];
			has[v] += stillneed[v];
		}
	}
	//cout << "has[" << u << "] = " << has[u] << endl;
	if(has[u] >= need[u]){
		stillneed[u] = 0;
		if(pa[u] != u)
			has[pa[u]] += has[u] - need[u];
		has[u] = need[u];
	} else {
		stillneed[u] = need[u] - has[u];
	}
}

signed main(){
	cin >> N;
	fill(isViable, isViable + N, true);
	fill(isLeaf, isLeaf + N, true);
	for(int i = 0; i < N; i++) cin >> has[i];
	for(int i = 0; i < N; i++) cin >> need[i];
	for(int i = 1; i < N; i++){
		cin >> pa[i] >> wei[i];
		pa[i]--;
		chi[pa[i]].push_back(i);
		isLeaf[pa[i]] = false;
	}
	dfs();
	cout << (has[0] >= need[0] && isViable[0] ? "YES" : "NO") << endl;
}