// #include <atcoder/all>
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double PI = acos(-1);
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
    return a < b && (a = b, true);
}
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
    return a > b && (a = b, true);
}
/*-------------------------------------------*/

int n;
int a[200], b[200];

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

    cin >> n;
    int c[200]{};
    rep(i, n) {
        cin >> a[i] >> b[i];
        if(a[i] != -1) c[--a[i]]++;
        if(b[i] != -1) c[--b[i]]++;
    }

    rep(i, 2 * n) if(c[i] > 1) {
        cout << "No\n";
        return 0;
    }

    int type[200]{};
    int dp[200];
    memset(dp, -1, sizeof(dp));
    dp[0] = 0;
    rep(i, n) {
        if(a[i] != -1) type[a[i]] = -(i + 1);
        if(b[i] != -1) type[b[i]] = (i + 1);
        if(a[i] == -1 && b[i] == -1) dp[0]++;
    }

    rep(i, n + 1) {
        rep(j, i) {
            int cnt = i - j;
            bool ok = true;
            FOR(k, j * 2, j + i) if(type[k] != 0) {
                if(type[k] > 0)
                    ok = false;
                else if(type[k + (i - j)] != 0 && type[k] != -type[k + (i - j)])
                    ok = false;
                cnt--;
            }
            FOR(k, j + i, i * 2) if(type[k] != 0) {
                if(type[k] < 0) ok = false;
                if(type[k - (i - j)] == 0) cnt--;
            }
            if(!ok) continue;
            chmax(dp[i], dp[j] - cnt);
        }
    }

    cout << (dp[n] >= 0 ? "Yes" : "No") << "\n";

    return 0;
}
#include <bits/stdc++.h>
using namespace std;

void fail(){
    cout << "No" << endl;
    exit(0);
}

int main(){
    int N;
    cin >> N;
    vector<int> A(N), B(N);
    vector<pair<int, int>> p2n(2*N+1, {-1, -1});
    for(int i=0; i<N; i++){
        cin >> A[i] >> B[i];
        if(A[i] != -1 && B[i] != -1 && A[i] >= B[i]) fail();
        if(A[i] != -1){
            if(p2n[A[i]].first != -1) fail();
            p2n[A[i]] = {i, 0};
        }
        if(B[i] != -1){
            if(p2n[B[i]].first != -1) fail();
            p2n[B[i]] = {i, 1};
        }
    }

    auto check = [&](int L, int R)->bool{
        int d = (R-L)/2;
        for(int l=L; l<L+d; l++){
            int r = l+d;
            auto [li, lc] = p2n[l];
            auto [ri, rc] = p2n[r];
            if(li != -1){
                if(lc != 0) return false;
                if(B[li] != -1 && B[li] != r) return false;
            }
            if(ri != -1){
                if(rc != 1) return false;
                if(A[ri] != -1 && A[ri] != l) return false;
            }
            if(li != -1 && ri != -1 && li != ri) return false;
        }
        return true;
    };

    vector<bool> ok(2*N+2);
    ok[1] = true;
    for(int i=1; i<=2*N; i+=2) if(ok[i]) for(int r=i+2; r<=2*N+1; r+=2){
        if(check(i, r)) ok[r] = true;
    }

    cout << (ok[2*N+1] ? "Yes" : "No") << endl;
    return 0;
}
