#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
const int MAXN = 2e5 + 10;
int n, h, l[MAXN], r[MAXN];
int32_t main() {
  scanf("%d", &n);
  set<int> s;
  for (int i = 1; i < n; i++) {
    s.insert(i);
  }
  for (int i = 0; i < n - 1; i++) {
    scanf("%d%d", &l[i], &r[i]);
    if (r[i] != n) {
      cout << "NO";
      return 0;
    }
    if (l[i] == n) {
      cout << "NO";
      return 0;
    }
    s.erase(l[i]);
  }
  sort(l, l + n, greater<int>());
  int last = n;
  vector<pair<int, int>> ans;
  for (int i = 0; i < n - 1;) {
    int j = i;
    while (j + 1 < n && l[j + 1] == l[j]) j++;
    for (int k = 1; k < (j - i + 1); k++) {
      if (s.empty() || *s.rbegin() > l[i]) {
        return cout << "NO", 0;
      } else {
        ans.push_back({last, *s.rbegin()});
        last = *s.rbegin();
        s.erase(*s.rbegin());
      }
    }
    ans.push_back({last, l[i]});
    last = l[i];
    i = j + 1;
  }
  cout << "YES\n";
  for (auto x : ans) {
    cout << x.first << " " << x.second << "\n";
  }
}
