// #include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <climits>
#include <string>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <ctime>
#include <cassert>
#include <fstream>
#include <stack>
#include <random>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<typename T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<typename T>
void vdeb(std::vector<T> &bb) {
    for (int i = 0;i < bb.size();i++) {
        if (i == bb.size() - 1) std::cout << bb[i];
        else std::cout << bb[i] << ' ';
    }
    std::cout << '\n';
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &bb) {
    for (int i = 0;i < bb.size();i++) {
        std::cout << i << ' ';
        vdeb(bb[i]);
    }
    std::cout << '\n';
}

using namespace std;

int main() {
    int n; cin >> n;
    vector<int> da(n*4, -2), daa(n*2, 0);
    rip(i,n,0) {
        int a,b; cin >> a >> b;
        --a;--b;
        if((a>=0  && da[a] != -2) || (b >= 0 &&da[b] != -2) || (a > b && a>= 0 && b >= 0)) {
            cout << "No" << endl;
            return 0;
        }
        if(a >= 0 && b >= 0) {
            da[a] = b;
            da[b] = a;
        }
        else if(a >= 0) {
            da[a] = -1;
            daa[a] = i+1;
        }
        else if(b >= 0) {
            da[b] = -3;
            daa[b] = i+1;
        }
    }
    vector<vector<bool>> dp(n*2, vector<bool>(n*2));
    // vdeb(da);
    rip(ii,n+1,1) {
        rip(jj,n+1-ii,0) {
            int i = jj, j = ii + jj, x = j-i;
            bool flg = true;
            // cout << i MM j MM x<< endl;
            rip(k, x, 0) {
                // cout << 2*i+k MM 2*i+k+x << endl;
                if(da[2*i+k] == 2*i+k+x || ((da[2*i+k] == -1 || da[2*i+k] == -2) && (da[2*i+k+x] == -2 || da[2*i+k+x] == -3))) {
                    if(da[2*i+k] == -1 && da[2*i+k+x] == -3) {
                        flg = false;
                        break;
                    }
                }
                else {
                    flg = false;
                    break;
                }
            }
            if(flg) dp[i][j] = true;
            else {
                rip(k, j, i+1) {
                    // cout << i MM k MM j << endl;
                    if(dp[i][k] && dp[k][j]) dp[i][j] = true;
                }
            }
        }
    }
    // vdeb(dp);
    if(dp[0][n]) cout << "Yes" << endl;
    else cout << "No" << endl;
}

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int N, A[105], B[105];

int out_pos[205];

int IN[205], OUT[205];

bool dp[205];

int check[205];

int tmp_in[205], tmp_out[205];

/*bool IsPossible(int I, int J, int K) {

	for (int i = I; i <= J; i++) { check[i] = 0; tmp_in[i] = IN[i]; tmp_out[i] = OUT[i]; }


	int id = 105;

	for (int i = I; i <= J; i++) {
		if (check[i] != 0) { continue; } // すでに出力済み
		
		if (tmp_out[i] != -1) {   return false; } // 入力の前に出力があるのは不合理

		if (tmp_in[i] > 0) { // 乗る人が確定している場合

			if (i + K + 1 > J) { return false; }
			else if (out_pos[i]>0) {
				if (out_pos[i] != i + K + 1) { return false; }
				else { tmp_out[i + K + 1] = tmp_in[i]; check[i + K + 1] = 1; }
			}
			else if (tmp_in[i+K+1]>0) {
				return false;
			}
			else if (tmp_out[i + K + 1] == -1 || tmp_out[i+K+1]==tmp_in[i]) {
				tmp_out[i + K + 1] = tmp_in[i]; check[i + K + 1] = 1;
			}
			else {  return false; }

		}
		else if (tmp_out[i+K+1]!=-1) { //降りる人が確定している場合
			tmp_in[i] = tmp_out[i + K + 1]; check[i + K + 1] = 1;
		}
		else { // 乗る人も降りる人も未確定の場合

			tmp_in[i] = id++;
			if (i + K + 1 > J) { return false; }
			else {
				tmp_out[i + K + 1] = tmp_in[i]; check[i + K + 1] = 1; 
			}

		}

	}

	return true;
}*/

bool IsPossible(int I, int J, int K) {

	for (int i = I; i <= J; i++) { check[i] = 0; tmp_in[i] = IN[i]; tmp_out[i] = OUT[i]; }

	for (int i = I; i <= J; i++) {
		if (check[i] != 0) { continue; }

		if (i + K + 1 > J) { return false; }

		if (tmp_in[i] > 0 && tmp_out[i+K+1] > 0) { // 乗る人と降りる人が確定
			if (out_pos[i] > 0 && out_pos[i] != i + K + 1) { return false; }

			if (tmp_in[i] != tmp_out[i + K + 1]) { return false; }

			check[i + K + 1] = 1;
		}
		else if (tmp_in[i]>0 && tmp_out[i+K+1]==-1) { // 乗る人のみ確定
			if (out_pos[i] > 0) { return false; }
			if (tmp_in[i + K + 1] > 0) { return false; } 
			else { check[i + K + 1] = 1; }
		}
		else if (tmp_in[i] == -1 && tmp_out[i + K + 1] > 0) { // 降りる人のみ確定
			check[i + K + 1] = 1;
		}
		else {//乗る人も降りる人も未確定
			if (tmp_in[i + K + 1] > 0) { return false; }
			check[i + K + 1] = 1;
		}

	}

	return true;
}

int main(void) {

	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> A[i] >> B[i];
	}

	for (int i = 1; i <= 2*N; i++) {
		IN[i] = -1; OUT[i] = -1;
	}

	for (int i = 1; i <= N; i++) {
		if (A[i]>0 && B[i]>0 && A[i] >= B[i]) { cout << "No" << endl; return 0; }

		if (A[i] > 0) {
			if (IN[A[i]] != -1) { cout << "No" << endl; return 0; }
			else { IN[A[i]] = i; }
		}

		if (B[i] > 0) {
			if (OUT[B[i]] != -1) { cout << "No" << endl; return 0; }
			else { OUT[B[i]] = i; }
		}
	}

	for (int i = 1; i <= 2 * N; i++) {
		if (IN[i] > 0 && OUT[i] > 0) { cout << "No" << endl; return 0; }
	}

	for (int i = 1; i <= 2 * N; i++) { out_pos[i] = -1; }
	for (int i = 1; i <= N; i++) {
		if (A[i] > 0 && B[i] > 0) { out_pos[A[i]] = B[i]; }
	}
	

	for (int i = 1; i <= N*2; i++) { dp[i] = false; }

	

	dp[0] = true;

	for (int i = 0; i < N*2; i+=2) {
		if (dp[i] == false) { continue; }

		for (int j = i + 2; j <= 2 * N; j += 2) {
			for (int k = 0; k <= N; k++) {
				if (IsPossible(i + 1, j, k)) { dp[j] = true; break; }
			}
		}
	}

	if (dp[2 * N] == true) { cout << "Yes" << endl; }
	else { cout << "No" << endl; }


	return 0;
}