#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

llint n;
llint l[105], r[105];
llint a[205], b[205], f[205];
bool dp[205][205];

int check(llint L, llint R)
{
	llint id = a[L];
	if(id == 0){
		if(a[R] == 0) return 1;
		else{
			if(b[R] == 1 && f[R] == 1) return 0;
			else return 1e6;
		}
	}
	else{
		if(r[id] != -1 && r[id] != R) return 1e6;
		return 0;
	}
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	llint m = 0;
	for(int i = 1; i <= n; i++){
		cin >> l[i] >> r[i];
		if(l[i] != -1) a[l[i]] = i, b[l[i]] = 0;
		if(r[i] != -1) a[r[i]] = i, b[r[i]] = 1;
		if(l[i] == -1 && r[i] != -1) f[r[i]] = 1;
		if(l[i] == -1 && r[i] == -1) m++;
	}
	
	dp[0][0] = true;
	for(int i = 0; i < 2*n; i++){
		if(b[i+1] == 1) continue;
		for(int j = 0; j <= m; j++){
			if(!dp[i][j]) continue;
			for(int k = i+2; k <= 2*n; k++){
				//cout << i+1 << " " << k << endl;
				
				if(check(i+1, k) > 1000) continue;
				//cout << i+1 << " " << k << endl;
				//if(id && r[id] != -1 && r[id] != j) continue;
				//if(id == 0 && a[j] != 0 && f[j] == 0) continue;
				int cnt = 0;
				cnt += check(i+1, k);
				for(int l = i+2; l < k; l++){
					cnt += check(l, l+(k-(i+1)));
					//cout << cnt << endl;
				}
				//cout << i+1 << " " << k << " " << cnt << endl;
				if(j+cnt <= m && (k-1)+(k-(i+1)) <= 2*n) dp[(k-1)+(k-(i+1))][j+cnt] = true;
			}
		}
	}
	
	/*for(int i = 0; i <= 2*n; i++){
		for(int j = 0; j <= m; j++){
			cout << dp[i][j] << " ";
		}
		cout << endl;
	}*/
	
	if(dp[2*n][m]) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pii = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;
 
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define per(i, b) per2(i, 0, b)
#define per2(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define ALL(c) (c).begin(), (c).end()
#define SZ(x) ((int)(x).size())
 
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
 
template <class T, class U>
void chmin(T& t, const U& u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
    if (t < u) t = u;
}
 
template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}
 
template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "{";
    rep(i, v.size()) {
        if (i) os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}
 
#ifdef LOCAL
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}
#define debug(...) \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif
 
int main() {
    int N;
    cin >> N;
    V<int> A(N), B(N);
    int sz = N * 2;
    V<int> tp(sz), com(sz, -1);
 
    bool ng = false;
 
    rep(i, N) {
        cin >> A[i] >> B[i];
        if (A[i] != -1) {
            --A[i];
            if (tp[A[i]]) ng = true;
            tp[A[i]] = i + 1;
        }
        if (B[i] != -1) {
            --B[i];
            if (tp[B[i]]) ng = true;
            tp[B[i]] = -(i + 1);
        }
 
        if (A[i] != -1 && B[i] != -1) {
            com[A[i]] = B[i];
            com[B[i]] = A[i];
        }
    }
    if (ng) {
        puts("No");
        return 0;
    }
 
    V<bool> dp(sz + 1);
    dp[0] = true;
 
    rep(i, sz) {
        if (!dp[i]) continue;
        for (int j = i + 1; j < sz; ++j) {
            int w = j - i + 1;
            if (w & 1) continue;
            w /= 2;
            bool ok = true;
 
            rep(k, w) {
                int p = i + k, q = i + k + w;
                if (com[p] != -1 && !(i <= com[p] && com[p] <= j)) {
                    ok = false;
                }
                if (com[q] != -1 && !(i <= com[q] && com[q] <= j)) {
                    ok = false;
                }
                if (tp[p] != 0 && tp[q] != 0) {
                    if (tp[p] < 0 || tp[p] + tp[q] != 0) {
                        ok = false;
                    } 
                }
                if (tp[p] < 0 || tp[q] > 0) {
                    ok = false;
                } else {
                    if (tp[p] != 0) {
                        int v = tp[p] - 1;
                    }
                }
            }
            if (ok) {
                dp[j + 1] = true;
            }
        }
    }
    puts(dp[sz] ? "Yes" : "No");
 
    return 0;
}
