#include <iostream>
int a[100];
int b[100];
int used[200];
int main() {
    int n;
    std::cin >> n;
    for (int i = 0; i < n; ++i) {
        std::cin >> a[i] >> b[i];
        if (a[i] != -1) ++used[a[i] - 1];
        if (b[i] != -1) ++used[b[i] - 1];
        if (a[i] != -1 and b[i] != -1 and a[i] >= b[i]) {
            std::cout << "No\n";
            return 0;
        }

        if (a[i] != -1 and used[a[i] - 1] == 2) {
            std::cout << "No\n";
            return 0;
        }

        if (b[i] != -1 and used[b[i] - 1] == 2) {
            std::cout << "No\n";
            return 0;
        }
    }
    int ilen, jlen, idx;
    for (int i = 0; i < n; ++i) {
        for (int j = i - 3; j < n; ++j) {
            if (i == j) continue;
            if (j < 0) continue;
            if (a[i] == -1 or b[i] == -1) continue;
            if (a[i] <= a[j] and a[j] <= b[i] and a[i] <= b[j] and b[j] <= b[i]) {
                std::cout << "No\n";
                return 0;
            }

            if (b[j] != -1) {
                if (a[i] <= a[j] and a[j] <= b[i]) {
                    ilen = b[i] - a[i] + 1;
                    jlen = b[j] - a[j] + 1;
                    if (ilen != jlen) {
                        std::cout << "No\n";
                        return 0;
                    }
                }
            } else {
                if (a[i] <= a[j] and a[j] <= b[i]) {
                    ilen = b[i] - a[i];
                    idx = a[j] + ilen - 1;
                    if (idx < 0 or 2 * n <= idx or used[idx] == 1) {
                        std::cout << "No\n";
                        return 0;
                    }
                }
            }

            if (a[j] != -1) {
                if (a[i] <= b[j] and b[j] <= b[i]) {
                    ilen = b[i] - a[i] + 1;
                    jlen = b[j] - a[j] + 1;
                    if (ilen != jlen) {
                        std::cout << "No\n";
                        return 0;
                    }
                }
            } else {
                if (a[i] <= b[j] and b[j] <= b[i]) {
                    ilen = b[i] - a[i];
                    idx = b[j] - ilen - 1;
                    if (idx < 0 or 2 * n <= idx or used[idx] == 1) {
                        std::cout << "No\n";
                        return 0;
                    }
                }
            }
        }
    }
    std::cout << "Yes\n";
}
// Template
#include "bits/stdc++.h"
#define rep_override(x, y, z, name, ...) name
#define rep2(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep3(i, l, r) for (int i = (int)(l); i < (int)(r); ++i)
#define rep(...) rep_override(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define per(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
constexpr int inf = 1001001001;
constexpr ll INF = 3003003003003003003LL;
template <typename T>
inline bool chmin(T &x, const T &y) {
    if (x > y) {
        x = y;
        return true;
    }
    return false;
}
template <typename T> 
inline bool chmax(T &x, const T &y) {
    if (x < y) {
        x = y;
        return true;
    }
    return false;
}
struct IOSET {
    IOSET() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
    }
} ioset;

// Main
int main() {
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    rep(i, n) {
        cin >> a[i] >> b[i];
        if (a[i] > 0) --a[i];
        if (b[i] > 0) --b[i];
    }

    vector<int> v(2 * n, -1);
    rep(i, n) {
        if (a[i] != -1) v[a[i]] = i;
        if (b[i] != -1) v[b[i]] = i + n;
    }

    int cnt = 0;
    rep(i, n) if (a[i] == -1 && b[i] == -1) ++cnt;
    auto dfs = [&](auto f, int now) -> void {
        // cout << now << "\n";
        if (now == 2 * n) {
            cout << "Yes\n";
            exit(0);
        }
        rep(i, 1, n + 1) {
            if (now + i * 2 > 2 * n) break;
            bool flag = true;
            int c = 0;
            rep(j, now, now + i) {
                if (v[j] >= n || (v[j + i] != -1 && v[j + i] < n)) {
                    flag = false;
                    break;
                }
                if (v[j] != -1) {
                    if (b[v[j]] != -1 && b[v[j]] != j + i) {
                        flag = false;
                        break;
                    }
                }
                if (v[j + i] != -1) {
                    if (a[v[j + i] - n] != -1 && a[v[j + i] - n] != j) {
                        flag = false;
                        break;
                    }
                }
                if (v[j] == -1 && v[i + j] == -1) ++c;
            }
            if (c > cnt) flag = false;
            if (!flag) continue;
            cnt -= c;
            f(f, now + 2 * i);
            cnt += c;
        }
    };
    dfs(dfs, 0);
    cout << "No\n";
}