Evlampiy was gifted a rooted tree. The vertices of the tree are numbered from 1 to n. Each of its vertices also has an integer a_i written on it. For each vertex i, Evlampiy calculated c_i — the number of vertices j in the subtree of vertex i, such that a_j < a_i. 

<image>Illustration for the second example, the first integer is a_i and the integer in parentheses is c_i

After the new year, Evlampiy could not remember what his gift was! He remembers the tree and the values of c_i, but he completely forgot which integers a_i were written on the vertices.

Help him to restore initial integers!

Input

The first line contains an integer n (1 ≤ n ≤ 2000) — the number of vertices in the tree.

The next n lines contain descriptions of vertices: the i-th line contains two integers p_i and c_i (0 ≤ p_i ≤ n; 0 ≤ c_i ≤ n-1), where p_i is the parent of vertex i or 0 if vertex i is root, and c_i is the number of vertices j in the subtree of vertex i, such that a_j < a_i.

It is guaranteed that the values of p_i describe a rooted tree with n vertices.

Output

If a solution exists, in the first line print "YES", and in the second line output n integers a_i (1 ≤ a_i ≤ {10}^{9}). If there are several solutions, output any of them. One can prove that if there is a solution, then there is also a solution in which all a_i are between 1 and 10^9.

If there are no solutions, print "NO".

Examples

Input


3
2 0
0 2
2 0


Output


YES
1 2 1 

Input


5
0 1
1 3
2 1
3 0
2 0


Output


YES
2 3 2 1 2
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
template <class T = int>
inline T readInt();
inline double readDouble();
inline int readUInt();
inline int readChar();
inline void readWord(char *s);
inline bool readLine(char *s);
inline bool isEof();
inline int getChar();
inline int peekChar();
inline bool seekEof();
inline void skipBlanks();
inline std::string readString();
template <class T>
inline void writeInt(T x, char end = 0, int len = -1);
inline void writeChar(int x);
inline void writeWord(const char *s);
inline void writeDouble(double x, int len = 0);
inline void flush();
static struct buffer_flusher_t {
  ~buffer_flusher_t() { flush(); }
} buffer_flusher;
using namespace std;
template <class T, class S>
inline void rmax(T &a, S b) {
  a = max(a, (T)b);
}
template <class T, class S>
inline void rmin(T &a, S b) {
  a = min(a, (S)b);
}
inline long long mul(long long a, long long b, long long m) {
  return a * b % m;
}
inline long long binpow(long long n, long long p, long long m) {
  if (!p) return 1;
  if (p & 1) return mul(n, binpow(n, p - 1, m), m);
  long long v = binpow(n, p / 2, m);
  return mul(v, v, m);
}
template <class T>
inline pair<T, T> gcdex(T a, T b) {
  if (b == 0) return {1, 0};
  auto [x, y] = gcdex(b, a % b);
  return {y, x - a / b * y};
}
inline bool is_prime(long long n) {
  for (long long i = 2; i * i <= n; ++i)
    if (n % i == 0) return 0;
  return 1;
}
inline vector<long long> factor(long long n) {
  vector<long long> ans;
  for (long long i = 2; i * i <= n; ++i)
    while (n % i == 0) ans.push_back(i), n /= i;
  if (n != 1) ans.push_back(n);
  return ans;
}
inline vector<long long> divisors(long long n) {
  vector<long long> ret;
  for (long long i = 1; i * i <= n; ++i) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  return ret;
}
inline vector<pair<long long, int>> factor_pows(long long n) {
  auto fac = factor(n);
  vector<pair<long long, int>> ret;
  int L = 0;
  while (L < (int)fac.size()) {
    int R = L;
    while (R < (int)fac.size() && fac[R] == fac[L]) ++R;
    ret.push_back({fac[L], R - L});
    L = R;
  }
  return ret;
}
inline long long gen_random_prime(long long L = (int)1e9) {
  L += rand() % 4242;
  while (!is_prime(L)) ++L;
  return L;
}
inline long long nmod(long long a, long long m) { return (a % m + m) % m; }
inline int mrand() { return abs((1LL * rand() << 15) + rand()); }
struct HashedString {
  string second;
  vector<long long> MOD, POW;
  vector<vector<long long>> hash42;
  vector<vector<long long>> pows;
  string substr(int L, int n) { return second.substr(L, n); }
  int size() const { return second.size(); }
  char operator[](int n) const { return second[n]; }
  vector<long long> get_hash(int L, int R) {
    vector<long long> ret;
    for (int i = 0; i < (int)hash42.size(); ++i) {
      ret.push_back(nmod(hash42[i][R] - hash42[i][L] * pows[i][R - L], MOD[i]));
    }
    return ret;
  }
  bool equal(int L1, int R1, int L2, int R2) {
    return get_hash(L1, R1) == get_hash(L2, R2);
  }
  void operator+=(char c) {
    second += c;
    for (int i = 0; i < (int)hash42.size(); ++i) {
      long long m = MOD[i], p = POW[i], cp = pows[i].back(),
                cm = hash42[i].back();
      cm = (cm * p + c) % m, cp = cp * p % m;
      hash42[i].push_back(cm);
      pows[i].push_back(cp);
    }
  }
  void operator+=(const string &oth) {
    for (char c : oth) (*this) += c;
  }
  HashedString(const string &second, int n = 1) {
    for (int i = 0; i < n; ++i) {
      MOD.push_back(gen_random_prime());
      POW.push_back(gen_random_prime());
      hash42.push_back({0}), pows.push_back({1});
    }
    (*this) += second;
  }
};
inline void init() {
  srand(time(0));
  ios_base::sync_with_stdio(0);
  cin.tie(0);
}
const int INF = 1e9;
int n;
const int MAXN = 1e5 + 42;
vector<int> gr[MAXN];
int p[MAXN];
int c[MAXN];
int col[MAXN];
void dfs(int v, vector<int> &st) {
  for (int u : gr[v]) {
    st.push_back(u);
    dfs(u, st);
  }
}
void rename(int v) {
  vector<int> vertices;
  dfs(v, vertices);
  sort(vertices.begin(), vertices.end(),
       [&](int a, int b) { return col[a] < col[b]; });
  for (int i = 1; i < vertices.size(); ++i) {
    if (col[vertices[i]] <= col[vertices[i - 1]]) {
      col[vertices[i]] = col[vertices[i - 1]] + 1;
    }
  }
  if (c[v] > vertices.size()) {
    cout << "NO\n";
    exit(0);
  }
  if (c[v] == 0) {
    col[v] = 1;
  } else {
    col[v] = col[vertices[c[v] - 1]] + 1;
  }
  for (int i = c[v]; i < vertices.size(); ++i) {
    col[vertices[i]]++;
  }
}
int main() {
  init();
  int n = readInt();
  int root = 0;
  queue<int> q;
  for (int i = 0; i < n; ++i) {
    p[i] = readInt() - 1;
    if (p[i] != -1) {
      gr[p[i]].push_back(i);
    } else {
      root = i;
    }
    c[i] = readInt();
  }
  if (n == 1) {
    if (c[0] == 0) {
      cout << "YES\n1\n";
    } else {
      cout << "NO\n";
    }
    return 0;
  }
  vector<int> in(n, 0);
  for (int i = 0; i < n; ++i) {
    if (gr[i].empty()) {
      q.push(i);
      col[i] = 1;
      if (c[i] != 0) {
        cout << "NO\n";
        return 0;
      }
    }
  }
  while (q.front() != root) {
    int v = q.front();
    q.pop();
    if (++in[p[v]] == gr[p[v]].size()) {
      rename(p[v]);
      q.push(p[v]);
    }
  }
  cout << "YES\n";
  for (int i = 0; i < n; ++i) {
    cout << col[i] << ' ';
  }
  cout << endl;
}
static const int buf_size = 4 * 4096;
static unsigned char buf[buf_size];
static int buf_len = 0, buf_pos = 0;
inline string readString() {
  const int MAX = 1e6 + 42;
  static char buf[MAX];
  readWord(buf);
  return string(buf);
}
inline bool isEof() {
  if (buf_pos == buf_len) {
    buf_pos = 0, buf_len = fread(buf, 1, buf_size, stdin);
    if (buf_pos == buf_len) return 1;
  }
  return 0;
}
inline int getChar() { return isEof() ? -1 : buf[buf_pos++]; }
inline int peekChar() { return isEof() ? -1 : buf[buf_pos]; }
inline bool seekEof() {
  int c;
  while ((c = peekChar()) != -1 && c <= 32) buf_pos++;
  return c == -1;
}
inline void skipBlanks() {
  while (!isEof() && buf[buf_pos] <= 32U) buf_pos++;
}
inline int readChar() {
  int c = getChar();
  while (c != -1 && c <= 32) c = getChar();
  return c;
}
inline int readUInt() {
  int c = readChar(), x = 0;
  while ('0' <= c && c <= '9') x = x * 10 + c - '0', c = getChar();
  return x;
}
template <class T>
inline T readInt() {
  int second = 1, c = readChar();
  T x = 0;
  if (c == '-')
    second = -1, c = getChar();
  else if (c == '+')
    c = getChar();
  while ('0' <= c && c <= '9') x = x * 10 + c - '0', c = getChar();
  return second == 1 ? x : -x;
}
inline double readDouble() {
  int second = 1, c = readChar();
  double x = 0;
  if (c == '-') second = -1, c = getChar();
  while ('0' <= c && c <= '9') x = x * 10 + c - '0', c = getChar();
  if (c == '.') {
    c = getChar();
    double coef = 1;
    while ('0' <= c && c <= '9') x += (c - '0') * (coef *= 1e-1), c = getChar();
  }
  return second == 1 ? x : -x;
}
inline void readWord(char *second) {
  int c = readChar();
  while (c > 32) *second++ = c, c = getChar();
  *second = 0;
}
inline bool readLine(char *second) {
  int c = getChar();
  while (c != '\n' && c != -1) *second++ = c, c = getChar();
  *second = 0;
  return c != -1;
}
static int write_buf_pos = 0;
static char write_buf[buf_size];
inline void writeChar(int x) {
  if (write_buf_pos == buf_size)
    fwrite(write_buf, 1, buf_size, stdout), write_buf_pos = 0;
  write_buf[write_buf_pos++] = x;
}
inline void flush() {
  if (write_buf_pos)
    fwrite(write_buf, 1, write_buf_pos, stdout), write_buf_pos = 0;
}
template <class T>
inline void writeInt(T x, char end, int output_len) {
  if (x < 0) writeChar('-'), x = -x;
  char second[24];
  int n = 0;
  while (x || !n) second[n++] = '0' + x % 10, x /= 10;
  while (n < output_len) second[n++] = '0';
  while (n--) writeChar(second[n]);
  if (end) writeChar(end);
}
inline void writeWord(const char *second) {
  while (*second) writeChar(*second++);
}
inline void writeDouble(double x, int output_len) {
  if (x < 0) writeChar('-'), x = -x;
  int t = (int)x;
  writeInt(t), x -= t;
  writeChar('.');
  for (int i = output_len - 1; i > 0; i--) {
    x *= 10;
    t = std::min(9, (int)x);
    writeChar('0' + t), x -= t;
  }
  x *= 10;
  t = std::min(9, (int)(x + 0.5));
  writeChar('0' + t);
}
