#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, j;

    for (int i = 1; i < n; ++i) {
        j = i - 1;

        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;
                }
            }
        }
    }

    for (int i = 0; i < n; ++i) {
        for (int j = i; j < n; ++j) {
            if (i == j) 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";
}
#include <bits/stdc++.h>
#include<random>
using namespace std; typedef unsigned long long _ulong; typedef long long int lint; typedef pair<lint, lint> plint; typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define endk '\n'
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
const lint MOD = 1e9 + 7, INF = 1e18;
lint dx[8] = { 0, -1, 1, 0, 1, -1, 1, -1 }, dy[8] = { 1, 0, 0, -1, -1, -1, 1, 1 };
typedef pair<long double, lint> Pa;
typedef pair<lint, plint> tlint;
struct edge {
	lint cost;
	lint u, v;
};
lint N, A[100], B[100];
vector<plint> ok;
lint now[200];
bool used[200];
bool dfs(lint curr, lint cnt) {
	if (cnt <= 0) return true;
	bool ans = false;
	IFOR(i, 1, cnt + 1) {
		bool _can = true;
		REP(j, i) {
			if (now[curr + j] < 2 * N && now[curr + j] >= N) _can = false;
			if (now[curr + j + i] < N) _can = false;
			if (now[curr + j] != 2 * N && now[curr + j + i] != 2 * N) {
				if (now[curr + j] + N != now[curr + i + j]) _can = false;
			}
			bool change = false;
			if (now[curr + j] < N) {
				if (used[now[curr + j]]) _can = false;
				used[now[curr + j]] = true;
				change = true;
			}
			if (now[curr + j + i] < 2 * N && now[curr + j + i] >= N) {
				if (!change && used[now[curr + j + i] - N]) _can = false;
				used[now[curr + j + i] - N] = true;
			}
		}
		if (!ans && _can) ans |= dfs(curr + i * 2, cnt - i);
		REP(j, i) {
			if (now[curr + j] < N) {
				used[now[curr + j]] = false;
			}
			if (now[curr + j + i] < 2 * N && now[curr + j + i] >= N) {
				used[now[curr + j + i] - N] = false;
			}
		}
	}
	return ans;
}
int main() {
	cin >> N;
	bool flag = true;
	REP(i, N * 2) {
		now[i] = N * 2;
	}
	REP(i, N) {
		cin >> A[i] >> B[i]; A[i]--; B[i]--;
		if (A[i] != -2) {
			if (now[A[i]] != N * 2) flag = false;
			now[A[i]] = i;
		}
		if (B[i] != -2) {
			if (now[B[i]] != N * 2) flag = false;
			now[B[i]] = i + N;
		}
		if (A[i] != -2 && B[i] != -2) {
			if (A[i] >= B[i]) {
				flag = false;
			}
		}
		used[i] = false;
	}
	if (flag && dfs(0, N)) cout << "Yes" << endk;
	else cout << "No" << endk;
}
