#include <bits/stdc++.h>
using namespace std;
const int MAXN = 105;
int from[MAXN], to[MAXN];
int dp[2 * MAXN];
int r = 0;
int N;
int valid(int l, int r) {
	if (r % 2 == l % 2) return 123456;
	//cerr << "check " << l << " " << r << endl;
	int len = r - l + 1, m = (l + r) / 2;
	vector<bool> can(len / 2, false);
	for (int i = 1; i <= N; i++) {
		if (from[i] != -1 && to[i] != -1) {
			if (from[i] >= l && from[i] <= m && to[i] > m && to[i] <= r && to[i] - from[i] == len / 2) {
				can[from[i] - l] = true;
			}
		} else if (from[i] != -1) {
			if (from[i] >= l && from[i] <= m) {
				if (can[from[i] - l]) {
					//cerr << "INF" << endl;
					return 123456;
				}
				can[from[i] - l] = true;
			}
		} else {
			if (to[i] > m && to[i] <= r) {
				if (can[to[i] - len / 2 - l]) {
					//cerr << "INF" << endl;
					return 123456;
				}
				can[to[i] - len / 2 - l] = true;
			}
		}
	}
	int ans = 0;
	for (int i = 0; i < len / 2; i++) {
		if (can[i]) ans += 1;
	}
	int need = len / 2 - ans;
	//cerr << need << endl;
	return need;
}
int main() {
	cin >> N;
	int real_n = N;
	set<int> vals;
	for (int i = 1; i <= N; i++) {
		cin >> from[i] >> to[i];
		if (from[i] > -1 && to[i] > -1 && from[i] >= to[i]) return 0 * puts("No");
		if (from[i] != -1) {
			if (vals.count(from[i])) return 0 * puts("No");
			vals.insert(from[i]);
		}
		if (to[i] != -1) {
			if (vals.count(to[i])) return 0 * puts("No");
			vals.insert(to[i]);
		}
		if (from[i] == -1 && to[i] == -1) {
			i -= 1;
			N -= 1;
			r += 1;
		}
	}

	dp[0] = 0;
	for (int i = 1; i <= 2 * real_n; i++) {
		dp[i] = 123456;
		for (int j = 1; j <= i; j++) {
			int cur = dp[j - 1] + valid(j, i);
			//cerr << j << " tries " << cur << endl;
			dp[i] = min(dp[i], cur);
		}
		//cerr << "dp_res: " << i << " " << dp[i] << endl;
	}
	cout << (dp[2 * real_n] <= r ? "Yes" : "No") << endl;
	return 0;
}
#include <bits/stdc++.h>
using namespace std;
//using namespace atcoder;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define pb push_back
#define fi first
#define se second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void chOut(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using v_bool = vector<bool>;
using v_Pii = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;



signed main(){

    int N; cin >> N;
    vec A(N), B(N);

    vec flg(2 * N + 1, 0), to(2 * N + 1, -1), from(2 * N + 1, -1);
    REP(i, N){
        cin >> A[i] >> B[i];
        /*if(A[i] > 0 && B[i] > 0 && A[i] > B[i]){
            Out("No");
            return 0;
        }*/
        if(A[i] > 0) flg[A[i]] = 1;
        if(B[i] > 0) flg[B[i]] = -1;
        if(A[i] > 0 && B[i] > 0){
            to[A[i]] = B[i];
            from[B[i]] = A[i];
        }
    }
    REP(i, N) REP(j, N){
        if(A[i] > 0 && B[j] > 0 && A[i] == B[j]){
            Out("No");
            return 0;
        }
        if(A[i] > 0 && A[j] > 0 && A[i] == A[j] && i != j){
            Out("No");
            return 0;
        }
        if(B[i] > 0 && B[j] > 0 && B[i] == B[j] && i != j){
            Out("No");
            return 0;
        }
    }

    v_bool pos(2 * N + 1, false);
    pos[0] = true;
    FOR(i, 1, 2 * N + 1){
        FOR(k, 1, N + 1){
            int j = i - 2 * k;
            if(j < 0 || !pos[j]) continue;

            bool ok = true;
            FOR(x, 1, k + 1){
                if(flg[j + x] == -1 || flg[j + k + x] == 1) ok = false;
                else if(flg[j + x] == 1 && flg[j + k + x] == -1){
                    if(to[j + x] != j + k + x || from[j + k + x] != j + x) ok = false;
                }else if(flg[j + x] == 1){
                    if(to[j + x] > 0 && to[j + x] != j + k + x) ok = false;
                }else if(flg[j + k + x] == -1){
                    if(from[j + k + x] > 0 && from[j + k + x] != j + x) ok = false;
                }
            }
            if(ok) pos[i] = true;
        }
    }
    chOut(pos[2 * N], "Yes", "No");

    return 0;
}
