#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll> pql;
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef map<ll, ll> ml;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, k, n) for(ll i = ll(k); i <= ll(n); i++)
#define rep3(i, n, k) for(ll i = ll(n); i >= ll(k); i--)
#define all(v) (v).begin(), (v).end()
ll mod(ll a, ll b) {return (a % b + b) % b;}
ll quo(ll a, ll b) {return (a - mod(a, b)) / b;}
template <typename T, typename U> bool chmin(T &a, const U b) {if(a > b) {a = b; return 1;} return 0;}
template <typename T, typename U> bool chmax(T &a, const U b) {if(a < b) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 2e5;
const ld eps = 1e-9;
const char newl = '\n';

ll itr1, itr2, M1 = 0, M2 = 0;
bool found = 0;
vl e, d1, d2;
vb diam;
vvl G;

void dfs1(ll v) {
  for(ll u: G[v]) {
    if(d1[u] == INF) {
      d1[u] = d1[v] + 1;
      dfs1(u);
    }
  }
  return;
}

void dfs2(ll v) {
  for(ll u: G[v]) {
    if(d2[u] == INF) {
      d2[u] = d2[v] + 1;
      dfs2(u);
    }
  }
  return;
}

void dfs3(ll v) {
  if(v == itr2) {
    found = 1;
    return;
  }
  for(ll u: G[v]) {
    if(found) break;
    if(d2[v] < d2[u]) dfs3(u);
    if(found) diam[u] = 1;
  }
  return;
}

ll dfs4(ll v, ll num) {
  e[v] = num;
  ll last = -1;
  for(ll u: G[v]) {
    if(e[u] == INF) {
      if(diam[u]) {
        last = u;
        continue;
      }
      num = dfs4(u, num+1);
    }
  }
  if(last != -1) num = dfs4(last, num+1);
  return num+1;
}

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

  ll n, a, b;
  cin >> n;
  e = vl(n, INF);
  d1 = vl(n, INF);
  d2 = vl(n, INF);
  diam = vb(n, 0);
  G = vvl(n);
  rep(_, n-1) {
    cin >> a >> b;
    a--, b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  d1[0] = 0;
  dfs1(0);
  rep(i, n) if(chmax(M1, d1[i])) itr1 = i;
  d2[itr1] = 0;
  dfs2(itr1);
  rep(i, n) if(chmax(M2, d2[i])) itr2 = i;
  dfs3(itr1);
  dfs4(itr1, 1);
  //cout << itr1 << " " << itr2 << newl;
  //rep(i, n) if(diam[i]) cout <<i << newl;
  rep(i, n) cout << e[i] << ' ';
  cout << newl;
  return 0;
} 
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

template<typename T>
ostream& operator<<(ostream &os, vector<T> &v){
    string sep = " ";
    if(v.size()) os << v[0];
    for(int i=1; i<v.size(); i++) os << sep << v[i];
    return os;
}

template<typename T>
istream& operator>>(istream &is, vector<T> &v){
    for(int i=0; i<v.size(); i++) is >> v[i];
    return is;
}

#ifdef DBG
void debug_(){ cout << endl; }
template<typename T, typename... Args>
void debug_(T&& x, Args&&... xs){
    cout << x << " "; debug_(forward<Args>(xs)...);
}
#define dbg(...) debug_(__VA_ARGS__)
#else
#define dbg(...)
#endif

int main() {
    ios_base::sync_with_stdio(false);
    cout << setprecision(20) << fixed;

    int n; cin >> n;
    vector<int> s(2*n), d(2*n);
    for(int i=0; i<n; i++){
        int a, b; cin >> a >> b;
        a--; b--;
        if(a>=0&&b>=0){
            if(b<=a||s[a]!=0||s[b]!=0) {
                cout << "No" << endl;
                return 0;
            }
            s[a] = (i+1);
            s[b] = -(i+1);
            d[a] = b-a;
            d[b] = a-b;
        } else if(a>=0){
            if(s[a]!=0){
                cout << "No" << endl;
                return 0;
            }
            s[a] = i+1;
        } else if(b>=0){
            if(s[b]!=0){
                cout << "No" << endl;
                return 0;
            }
            s[b] = -(i+1);
        }
    }

    vector<bool> dp(n+1);

    dp[0] = true;

    for(int i=0; i<n; i++){
        if(!dp[i]) continue;
        for(int j=1; i+j<=n; j++){
            bool ok = true;
            for(int k=0; k<j; k++){
                int p = 2*i+k, q = 2*i+j+k;
                if(d[p]!=0&&d[p]!=j) ok = false;
                if(d[q]!=0&&d[q]!=-j) ok = false;

                if(s[p]!=0&&s[q]!=0&&s[p]+s[q]!=0) ok = false;
                if(s[p]<0 || 0<s[q]) ok = false;
            }
            dp[i+j] = dp[i+j] || ok;
        }
    }

    cout << (dp[n]?"Yes":"No") << endl;

    return 0;
}