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

NO
 NO
 NO
 YES
 NO
 NO

#include <bits/stdc++.h>
#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
using namespace std;
using namespace tr1;
double __begin;
template <class T1, class T2, class T3>
struct triple {
  T1 a;
  T2 b;
  T3 c;
  triple() : a(T1()), b(T2()), c(T3()){};
  triple(T1 _a, T2 _b, T3 _c) : a(_a), b(_b), c(_c) {}
};
template <class T1, class T2, class T3>
bool operator<(const triple<T1, T2, T3>& t1, const triple<T1, T2, T3>& t2) {
  if (t1.a != t2.a)
    return t1.a < t2.a;
  else if (t1.b != t2.b)
    return t1.b < t2.b;
  else
    return t1.c < t2.c;
}
template <class T1, class T2, class T3>
bool operator>(const triple<T1, T2, T3>& t1, const triple<T1, T2, T3>& t2) {
  if (t1.a != t2.a)
    return t1.a > t2.a;
  else if (t1.b != t2.b)
    return t1.b > t2.b;
  else
    return t1.c > t2.c;
}
inline int bits_count(int v) {
  v = v - ((v >> 1) & 0x55555555);
  v = (v & 0x33333333) + ((v >> 2) & 0x33333333);
  return ((v + (v >> 4) & 0xF0F0F0F) * 0x1010101) >> 24;
}
inline int bits_count(long long v) {
  int t = v >> 32;
  int p = (v & ((1LL << 32) - 1));
  return bits_count(t) + bits_count(p);
}
unsigned int reverse_bits(register unsigned int x) {
  x = (((x & 0xaaaaaaaa) >> 1) | ((x & 0x55555555) << 1));
  x = (((x & 0xcccccccc) >> 2) | ((x & 0x33333333) << 2));
  x = (((x & 0xf0f0f0f0) >> 4) | ((x & 0x0f0f0f0f) << 4));
  x = (((x & 0xff00ff00) >> 8) | ((x & 0x00ff00ff) << 8));
  return ((x >> 16) | (x << 16));
}
template <class T>
inline int sign(T x) {
  return x > 0 ? 1 : x < 0 ? -1 : 0;
}
inline bool isPowerOfTwo(int x) { return (x != 0 && (x & (x - 1)) == 0); }
template <class T1, class T2, class T3>
T1 inline clamp(T1 x, const T2& a, const T3& b) {
  if (x < a)
    return a;
  else if (x > b)
    return b;
  else
    return x;
}
unsigned long long rdtsc() {
  unsigned long long ret;
  __asm__ __volatile__("rdtsc" : "=A"(ret) : :);
  return ret;
}
template <class T = int>
T read_int() {
  const int B = 4096;
  static char b[B + 16], *e = b + B, *i = e;
  auto c = [&]() {
    if (i == e) memset(b, 0, B), cin.read(b, B), i = b;
  };
  c();
  while (*i && (*i < '0' || *i > '9') && *i != '-') ++i;
  c();
  bool m = false;
  if (*i == '-') ++i, c(), m = true;
  T r = 0;
  while (*i >= '0' && *i <= '9') r = r * 10 + *i - '0', ++i, c();
  ++i;
  return m ? -r : r;
}
template <class T>
void write_int(T x, char endc = '\n') {
  const int B = 4096;
  static char b[B + 20], *i = b, *e = b + B;
  if (x < 0) *i++ = '-', x = -x;
  if (x == 0) *i++ = '0';
  char* s = i;
  while (x) {
    T t = x / 10;
    char c = x - 10 * t + '0';
    *i++ = c;
    x = t;
  }
  char* f = i - 1;
  while (s < f) swap(*s, *f), ++s, --f;
  if (i > e) cout.write(b, i - b), i = b;
  *i++ = endc;
  struct F {
    ~F() {
      if (i != b) cout.write(b, i - b);
    }
  };
  static F flush;
}
template <class T1, class T2>
ostream& operator<<(ostream& os, const pair<T1, T2>& p);
template <class T>
ostream& operator<<(ostream& os, const vector<T>& v);
template <class T1, class T2>
ostream& operator<<(ostream& os, const set<T1, T2>& v);
template <class T1, class T2>
ostream& operator<<(ostream& os, const multiset<T1, T2>& v);
template <class T1, class T2>
ostream& operator<<(ostream& os, priority_queue<T1, T2> v);
template <class T1, class T2, class T3>
ostream& operator<<(ostream& os, const map<T1, T2, T3>& v);
template <class T1, class T2, class T3>
ostream& operator<<(ostream& os, const multimap<T1, T2, T3>& v);
template <class T1, class T2, class T3>
ostream& operator<<(ostream& os, const triple<T1, T2, T3>& t);
template <class T1, class T2>
ostream& operator<<(ostream& os, const pair<T1, T2>& p) {
  return os << "(" << p.first << ", " << p.second << ")";
}
template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  bool f = 1;
  os << "[";
  for (auto& i : v) {
    if (!f) os << ", ";
    os << i;
    f = 0;
  }
  return os << "]";
}
template <class T1, class T2>
ostream& operator<<(ostream& os, const set<T1, T2>& v) {
  bool f = 1;
  os << "[";
  for (auto& i : v) {
    if (!f) os << ", ";
    os << i;
    f = 0;
  }
  return os << "]";
}
template <class T1, class T2>
ostream& operator<<(ostream& os, const multiset<T1, T2>& v) {
  bool f = 1;
  os << "[";
  for (auto& i : v) {
    if (!f) os << ", ";
    os << i;
    f = 0;
  }
  return os << "]";
}
template <class T1, class T2, class T3>
ostream& operator<<(ostream& os, const map<T1, T2, T3>& v) {
  bool f = 1;
  os << "[";
  for (auto& ii : v) {
    if (!f) os << ", ";
    os << "(" << ii.first << " -> " << ii.second << ") ";
    f = 0;
  }
  return os << "]";
}
template <class T1, class T2>
ostream& operator<<(ostream& os, const multimap<T1, T2>& v) {
  bool f = 1;
  os << "[";
  for (auto& ii : v) {
    if (!f) os << ", ";
    os << "(" << ii.first << " -> " << ii.second << ") ";
    f = 0;
  }
  return os << "]";
}
template <class T1, class T2>
ostream& operator<<(ostream& os, priority_queue<T1, T2> v) {
  bool f = 1;
  os << "[";
  while (!v.empty()) {
    auto x = v.top();
    v.pop();
    if (!f) os << ", ";
    f = 0;
    os << x;
  }
  return os << "]";
}
template <class T1, class T2, class T3>
ostream& operator<<(ostream& os, const triple<T1, T2, T3>& t) {
  return os << "(" << t.a << ", " << t.b << ", " << t.c << ")";
}
template <class T1, class T2>
void printarray(T1 a, T2 sz, T2 beg = 0) {
  for (T2 i = beg; i < sz; i++) cout << a[i] << " ";
  cout << endl;
}
template <class T1, class T2, class T3>
inline istream& operator>>(istream& os, triple<T1, T2, T3>& t);
template <class T1, class T2>
inline istream& operator>>(istream& os, pair<T1, T2>& p) {
  return os >> p.first >> p.second;
}
template <class T>
inline istream& operator>>(istream& os, vector<T>& v) {
  if (v.size())
    for (T& t : v) os >> t;
  else {
    string s;
    T obj;
    while (s.empty()) {
      getline(os, s);
      if (!os) return os;
    }
    stringstream ss(s);
    while (ss >> obj) v.push_back(obj);
  }
  return os;
}
template <class T1, class T2, class T3>
inline istream& operator>>(istream& os, triple<T1, T2, T3>& t) {
  return os >> t.a >> t.b >> t.c;
}
template <class T1, class T2>
inline pair<T1, T2> operator+(const pair<T1, T2>& p1, const pair<T1, T2>& p2) {
  return pair<T1, T2>(p1.first + p2.first, p1.second + p2.second);
}
template <class T1, class T2>
inline pair<T1, T2>& operator+=(pair<T1, T2>& p1, const pair<T1, T2>& p2) {
  p1.first += p2.first, p1.second += p2.second;
  return p1;
}
template <class T1, class T2>
inline pair<T1, T2> operator-(const pair<T1, T2>& p1, const pair<T1, T2>& p2) {
  return pair<T1, T2>(p1.first - p2.first, p1.second - p2.second);
}
template <class T1, class T2>
inline pair<T1, T2>& operator-=(pair<T1, T2>& p1, const pair<T1, T2>& p2) {
  p1.first -= p2.first, p1.second -= p2.second;
  return p1;
}
template <class T>
inline void normmod(T& x, T m) {
  x %= m;
  if (x < 0) x += m;
}
template <class T1, class T2>
inline T2 summodfast(T1 x, T1 y, T2 m) {
  T2 res = x + y;
  if (res >= m) res -= m;
  return res;
}
template <class T1, class T2, class T3>
inline void addmodfast(T1& x, T2 y, T3 m) {
  x += y;
  if (x >= m) x -= m;
}
template <class T1, class T2, class T3>
inline void submodfast(T1& x, T2 y, T3 m) {
  x -= y;
  if (x < 0) x += m;
}
inline long long mulmod(long long x, long long n, long long m) {
  long long r = 0;
  normmod(x, m);
  normmod(n, m);
  while (n) {
    if (n & 1) addmodfast(r, x, m);
    addmodfast(x, x, m);
    n /= 2;
  }
  return r;
}
inline long long mulmodfast(long long x, long long n, long long m) {
  long long r = 0;
  while (n) {
    if (n & 1) addmodfast(r, x, m);
    addmodfast(x, x, m);
    n /= 2;
  }
  return r;
}
inline long long powmod(long long x, long long n, long long m) {
  long long r = 1;
  normmod(x, m);
  while (n) {
    if (n & 1) r = (r * x) % m;
    x = (x * x) % m;
    n /= 2;
  }
  return r;
}
inline long long powmulmod(long long x, long long n, long long m) {
  long long res = 1;
  normmod(x, m);
  while (n) {
    if (n & 1) res = mulmod(res, x, m);
    x = mulmod(x, x, m);
    n /= 2;
  }
  return res;
}
template <class T>
inline T gcd(T a, T b) {
  while (b) {
    a %= b;
    T t = a;
    a = b;
    b = t;
  }
  return a;
}
inline long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
template <class T>
inline T gcd(T a, T b, T c) {
  return gcd(gcd(a, b), c);
}
long long gcdex(long long a, long long b, long long& x, long long& y) {
  if (!a) {
    x = 0;
    y = 1;
    return b;
  }
  long long y1;
  long long d = gcdex(b % a, a, y, y1);
  x = y1 - (b / a) * y;
  return d;
}
template <class T>
bool isPrime(T x) {
  if (x < 2) return 0;
  for (T i = 2; i * i <= x; ++i)
    if (x % i == 0) return 0;
  return 1;
}
bool millerRabin(long long n) {
  if (n <= 2) return n == 2;
  long long s = n - 1;
  int t = 0;
  while (s % 2 == 0) s /= 2, ++t;
  for (int a : {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37}) {
    if (a >= n) return a == n;
    long long f = powmulmod(a, s, n);
    if (f == 1 || f == n - 1) continue;
    for (int i = 1; i < t; ++i)
      if ((f = mulmodfast(f, f, n)) == n - 1) goto nextp;
    return false;
  nextp:;
  }
  return true;
}
long long a[101010];
long long b[101010];
long long cnt[101010];
vector<pair<int, int> > v[101010];
long long go(int cur) {
  for (pair<int, int> p : v[cur]) {
    a[cur] += go(p.first);
  }
  b[cur] -= a[cur];
  if (b[cur] < 0) {
    long long res = -b[cur];
    b[cur] = 0;
    return res;
  } else {
    return 0;
  }
}
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i] >> b[i];
  }
  for (int i = 0; i < n - 1; ++i) {
    int x, k;
    cin >> x >> k;
    cnt[i + 1] = k;
    v[x - 1].push_back({i + 1, k});
  }
  long long free = go(0);
  if (b[0] > 0) {
    cout << "NO" << endl;
    return 0;
  }
  for (int i = 1; i < n; ++i) {
    if (free / cnt[i] < b[i]) {
      cout << "NO" << endl;
      return 0;
    }
    free -= cnt[i] * b[i];
  }
  cout << "YES" << endl;
  return 0;
}
